Water level identification method and device, computer equipment and storage medium
By using the target detection model and deep learning neural network in the water level identification method, the water level is calculated based on the actual height of the water gauge and characters, which solves the problem of water level identification accuracy under the influence of environmental factors and improves the accuracy of flood and drought disaster judgments. .
Patent Information
- Application Number
- CN202410846004.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-29
AI Technical Summary
The water level identification method based on computer vision is affected by environmental factors such as lighting changes, water gauge occlusion, and camera angles. As a result, the accuracy of detection results and water level calculation accuracy cannot reach the ideal state, which affects the judgment of floods and drought disasters.
By obtaining the image to be detected, use the target detection model to detect the height of the water gauge and character target frame, calculate the average height and variance of the character target frame, filter the target frames that meet the preset conditions, and calculate the water level based on the actual height of the character and water gauge, and By modifying the deep learning neural network model, the water gauge and characters are placed in one detection model to reduce the number of models and algorithm complexity. The height of the water gauge and the proportion of characters in the image are used to calculate the length of the water gauge to avoid inaccurate number of character detections. resulting errors.
It improves the accuracy of water level recognition, reduces the probability of false detection, enhances the accuracy of results, avoids water level calculation errors caused by inaccurate character detection, and improves the reliability of flood and drought disaster judgments.
Smart Images

Figure CN118865403A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of water conservancy engineering, and in particular to a water level identification method, device, computer equipment and storage medium. Background Art
[0002] In water conservancy projects, water gauges are an important tool for water level monitoring. Now with the development of computer vision technology, the method of real-time monitoring of water gauges based on cameras has been updated from early traditional image processing methods such as image binarization and morphological processing to current target detection and recognition methods based on deep neural networks.
[0003] The water level recognition method based on computer vision mainly obtains the water gauge detection image from the camera, and then detects the position of the water gauge in the image, as well as the complete and incomplete characters E and characters on the water gauge. The length of the water ruler above the water surface is calculated by the number and length of characters in the image, thereby calculating the water level.
[0004] In actual application scenarios, due to environmental influences, such as lighting changes, partial occlusion of the water gauge, and camera angle, the accuracy of the water gauge and character detection results based on computer vision cannot reach the ideal state, which affects the accuracy of water level calculation and has a certain impact on the judgment of flood and drought disasters.
[0005] Therefore, in view of the shortcomings of the prior art solutions, the present invention provides a water level identification method that improves the accuracy of water level identification. Summary of the invention
[0006] Based on this, it is necessary to provide a water level identification method, device, computer equipment and storage medium to address the above technical problems.
[0007] On the one hand, a water level recognition method is provided, the method comprising: acquiring an image to be detected; wherein the image to be detected comprises a water ruler and characters on the water ruler; obtaining, through a target detection model, a height of a water ruler target frame corresponding to the water ruler in the image to be detected and a height of a character target frame corresponding to the characters on the water ruler, wherein one image to be detected comprises multiple characters and one character target frame comprises one character; calculating an average height and variance of the character target frames in the image to be detected, screening out character target frames that meet preset conditions, and obtaining a target average height of the character target frames in the image to be detected based on the character target frames that meet the preset conditions, wherein the preset conditions include that the height of the character target frame is within the range of the target average height plus / minus the variance value; and calculating the water level based on the actual height of the characters, the actual total height of the water ruler, the target average height of the character target frames, and the height of the water ruler target frame.
[0008] Optionally, before acquiring the image to be detected, the method also includes: acquiring a water ruler image, annotating the water ruler and characters in the water ruler in the water ruler image, and obtaining a water ruler and character detection training data set; training a modified deep learning neural network model using the water ruler and character detection training data set to obtain the target detection model.
[0009] Optionally, acquiring a water ruler image, annotating the water ruler and characters in the water ruler in the water ruler image, and obtaining a water ruler and character detection training data set, includes: acquiring the water ruler image, annotating the water ruler in the water ruler image, and obtaining the water ruler detection training data set; acquiring a partial water ruler image of the water ruler image; the aspect ratio of the partial water ruler image is less than or equal to a preset value; extracting characters in the partial water ruler image, annotating the characters in the partial water ruler image, and obtaining the character detection training data set.
[0010] Optionally, the modified deep learning neural network model is trained through the water gauge and character detection training data set to obtain the target detection model, including: modifying the network structure of the deep learning neural network model into a multi-task network; receiving the training images in the water gauge and character detection training data set through the input layer; performing feature extraction on the training images through the backbone network layer to generate a feature map corresponding to the training images; adding a network branch to the neck network layer, and performing feature fusion on the sub-feature map generated by the backbone network layer through the added network branch to obtain a shallow feature prediction map; and extracting the features of the training images from the backbone network layer through the neck network layer. The generated feature map is feature fused to obtain a deep feature prediction map; a detection head is added to the detection end layer, and characters are detected through the newly added detection head according to the shallow feature prediction map; the water ruler is detected through multiple detection heads of the detection end layer according to the deep feature prediction map; the detected water ruler and characters are marked in the training image, the loss is calculated through the loss function, and the deep learning neural network model is updated, wherein the first loss function is used as the loss function for the water ruler part in the deep learning neural network model, and the second loss function is used as the loss function for the character part in the deep learning neural network model.
[0011] Optionally, a new network branch is added to the neck network layer, and feature fusion is performed on the sub-feature map generated by the trunk network layer through the new network branch to obtain a shallow feature prediction map, including: upsampling the sub-feature map generated by the trunk network layer through the new network branch to obtain a shallower feature map, wherein the sub-feature map is a process feature map generated during the processing of the trunk network layer; and feature fusion is performed on the shallower feature map obtained by the new network branch and the sub-feature map to obtain a shallow feature prediction map.
[0012] Optionally, the modified deep learning neural network model is trained through the water ruler and character detection training data set to obtain the target detection model, including: training the deep learning neural network model multiple times through the water ruler and character detection training data set, and updating the deep learning neural network model; when the loss function of the deep learning neural network model reaches convergence, the target detection model is obtained.
[0013] Optionally, the water level is calculated based on the actual height of the character, the actual total height of the water ruler, the target average height of the character target frame and the height of the water ruler target frame, including: multiplying the ratio of the actual height of the character to the target average height of the character target frame by the height of the water ruler target frame to obtain the actual total height of the water ruler above the water; subtracting the actual total height of the water ruler above the water from the actual total height of the water ruler to obtain the water level; the calculation formula is: WL=LH÷EH×EL; wherein WL is the water level, L is the actual total height of the water ruler, H is the actual height of the character, EH is the target average height of the character target frame, and EL is the height of the water ruler target frame.
[0014] On the other hand, a water level recognition device is provided, the device comprising: an acquisition module, used to acquire an image to be detected; wherein the image to be detected includes a water ruler and characters on the water ruler; a detection module, used to obtain the height of a water ruler target frame corresponding to the water ruler in the image to be detected and the height of a character target frame corresponding to the characters on the water ruler through a target detection model, wherein one image to be detected includes multiple characters and one character target frame includes one character; a screening module, used to calculate the average height and variance of the character target frames in the image to be detected, screen out character target frames that meet preset conditions, and obtain the target average height of the character target frames in the image to be detected based on the character target frames that meet the preset conditions, wherein the preset conditions include that the height of the character target frame is within the range of the target average height plus / minus the variance value; a calculation module, used to calculate the water level based on the actual height of the characters, the actual total height of the water ruler, the target average height of the character target frame and the height of the water ruler target frame.
[0015] On the other hand, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: acquiring an image to be detected; wherein the image to be detected comprises a water ruler and characters on the water ruler; obtaining, through a target detection model, a height of a water ruler target frame corresponding to the water ruler in the image to be detected and a height of a character target frame corresponding to the characters on the water ruler, wherein one image to be detected comprises a plurality of characters, and one character target frame comprises one character; calculating an average height and variance of the character target frames in the image to be detected, screening out character target frames that meet preset conditions, and obtaining a target average height of the character target frames in the image to be detected based on the character target frames that meet the preset conditions, wherein the preset conditions comprise that the height of the character target frame is within the range of the target average height plus / minus the variance value; and calculating the water level based on the actual height of the characters, the actual total height of the water ruler, the target average height of the character target frames, and the height of the water ruler target frame.
[0016] On the other hand, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: obtaining an image to be detected; wherein the image to be detected includes a water ruler and characters on the water ruler; obtaining, through a target detection model, a height of a water ruler target frame corresponding to the water ruler in the image to be detected and a height of a character target frame corresponding to the characters on the water ruler, wherein one image to be detected includes multiple characters and one character target frame includes one character; calculating an average height and variance of the character target frames in the image to be detected, screening out character target frames that meet preset conditions, and obtaining a target average height of the character target frames in the image to be detected based on the character target frames that meet the preset conditions, wherein the preset conditions include that the height of the character target frame is within the range of the target average height plus / minus the variance value; and calculating the water level based on the actual height of the characters, the actual total height of the water ruler, the target average height of the character target frames, and the height of the water ruler target frame.
[0017] The above-mentioned water level recognition method, device, equipment and storage medium, the method includes: obtaining an image to be detected; wherein, the image to be detected includes a water gauge and characters on the water gauge; through a target detection model, obtaining the height of a water gauge target frame corresponding to the water gauge in the image to be detected and the height of a character target frame corresponding to the characters on the water gauge, wherein one image to be detected includes multiple characters and one character target frame includes one character; calculating the average height and variance of the character target frame in the image to be detected, screening out character target frames that meet preset conditions, and obtaining the target average height of the character target frame in the image to be detected based on the character target frame that meets the preset conditions, wherein the preset conditions include that the height of the character target frame is within the range of the target average height plus / minus the variance value; calculating the water level based on the actual height of the character, the actual total height of the water gauge, the target average height of the character target frame and the height of the water gauge target frame. In this way, by modifying the detection model, the water gauge and characters are placed in one detection model, the number of models is reduced, the algorithm and deployment complexity are reduced, and the detection accuracy is guaranteed while reducing the algorithm complexity; the water gauge length is calculated using the ratio of the water gauge height and the characters in the image, which avoids the problem of excessive error in water level calculation caused by inaccurate number of detected characters. At the same time, the detected characters are filtered using the height mean and height deviation to reduce the probability of false detection and improve the accuracy of the results. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 A schematic diagram of a flow chart of a water level identification method in one embodiment;
[0019] Figure 2 A modified yolov5 neural network structure diagram of a water level recognition method in one embodiment;
[0020] Figure 3 is a structural block diagram of a water level identification device in one embodiment;
[0021] Figure 4 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0023] It should be understood that in the description of the present application, unless the context clearly requires otherwise, words such as "include", "comprises", and the like throughout the specification should be interpreted as including rather than being exclusive or exhaustive; that is, as including but not limited to.
[0024] It should also be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, "plurality" means two or more.
[0025] It should be noted that the terms "S1", "S2", etc. are only used for the purpose of describing the steps, and do not specifically refer to the order or sequence, nor are they used to limit the present application. They are only for the convenience of describing the method of the present application, and cannot be understood as indicating the order of the steps. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present application.
[0026] In one embodiment, Figure 1 As shown, a water level identification method is provided, comprising the following steps:
[0027] S101: Acquire an image to be detected; wherein the image to be detected includes a water ruler and characters on the water ruler.
[0028] Here, the image to be detected also includes the image background, and the characters on the water ruler include the characters E and
[0029] Specifically, a camera may be arranged at the water level observation point, and the camera may capture images at regular intervals to obtain images to be detected; the regular intervals may be any preset duration such as half an hour or one hour.
[0030] S102: Obtaining the height of the water ruler target frame corresponding to the water ruler in the image to be detected and the height of the character target frame corresponding to the character on the water ruler through the target detection model, wherein one image to be detected includes multiple characters and one character target frame includes one character.
[0031] Here, the target detection model can be a modified ResNet101, SegNet, Faster RCNN, Yolo and other series of neural network models. The detection of water scale and characters is realized by a detection model; the character target box includes the character E target box or the character Target box; the height of the target box can be obtained by obtaining the coordinates of the vertices of the target box and obtaining the height of the target box by the height difference between the coordinates of the vertices, or by direct measurement.
[0032] Specifically, the target frames of the water ruler and the characters are detected by the target detection model. The water ruler target frame includes the part along the top of the water ruler to the boundary between the water ruler and the water surface, and the character target frame includes the character E or the character The whole of the pattern.
[0033] S103: Calculate the average height and variance of the character target frames in the image to be detected, screen out the character target frames that meet the preset conditions, and obtain the target average height of the character target frames in the image to be detected based on the character target frames that meet the preset conditions, wherein the preset conditions include that the height of the character target frame is within the range of the target average height plus / minus the variance value.
[0034] Here, the character target frame that does not meet the preset conditions may be due to the fact that the characters are worn, the characters are blocked, or multiple characters are mistakenly detected as one character during detection.
[0035] Specifically, multiple character target frames in the image to be detected are obtained, the average height and variance of the multiple character target frames are calculated, each character target frame is compared with the average height, character target frames that are too large or too small are filtered out, and the average height of the filtered character target frames is calculated as the character height in the image to be detected.
[0036] S104: Calculate the water level according to the actual height of the character, the actual total height of the water gauge, the target average height of the character target frame, and the height of the water gauge target frame.
[0037] Here, the actual height of the characters and the actual total height of the water gauge are obtained by acquiring the model of the water gauge in the image to be detected, and obtaining the water gauge height data and the character height data corresponding to the water gauge model.
[0038] Specifically, the actual height of the water gauge above the water surface can be obtained according to the ratio of the actual height to the height in the image, thereby obtaining the water level.
[0039] It should be noted that the present application modifies the detection model and places the water gauge and characters in one detection model, thereby reducing the number of models, reducing the algorithm and deployment complexity, and ensuring detection accuracy while reducing the algorithm complexity; the water gauge length is calculated using the ratio of the water gauge height and the character height in the image, thereby avoiding the problem of excessive error in water level calculation caused by inaccurate number of character detections, and at the same time, the detected characters are filtered using the height mean and height deviation to reduce the probability of false detection and improve the accuracy of the results.
[0040] In some specific implementations, before acquiring the image to be detected, the method further includes:
[0041] Acquire a water ruler image, and annotate the water ruler and characters in the water ruler in the water ruler image to obtain a water ruler and character detection training data set;
[0042] The modified deep learning neural network model is trained using the water gauge and character detection training data set to obtain the target detection model.
[0043] Here, by acquiring water level image data in different scenarios, a diverse data set can be obtained. For example, when acquiring infrared data at night, images that may be overexposed by infrared are acquired, or when the outdoor scene is complex, images that may be obstructed by foreign objects are acquired.
[0044] In this way, placing the water gauge and characters in the same neural network model reduces the number of models, reduces the complexity of algorithms and deployment, and reduces manual labeling and training costs.
[0045] In some specific implementations, the step of acquiring a water ruler image, annotating the water ruler and characters in the water ruler in the water ruler image, and obtaining a water ruler and character detection training data set includes:
[0046] Acquire the water gauge image, mark the water gauge in the water gauge image, and obtain the water gauge detection training data set;
[0047] Acquire a partial water gauge image of the water gauge image; the aspect ratio of the partial water gauge image is less than or equal to a preset value;
[0048] Characters in the partial water gauge image are extracted, and the characters in the partial water gauge image are labeled to obtain the character detection training data set.
[0049] Here, a water ruler image can extract multiple partial water ruler images with different aspect ratios. Assuming that the preset value of the aspect ratio is 4, partial water ruler images with aspect ratios of 3, 3.5 or 4 can be obtained in the water ruler image, and the characters in the partial water ruler images can be marked.
[0050] Specifically, a water ruler image is obtained, the water ruler is firstly marked, and then a partial water ruler image with an aspect ratio within a preset range is obtained, and characters in the partial image are marked.
[0051] In this way, for small target characters, the accuracy of character annotation can be improved by selecting part of the water level image to annotate the characters.
[0052] In some specific implementations, the modified deep learning neural network model is trained using the water gauge and character detection training data set to obtain the target detection model, including:
[0053] Modifying the network structure of the deep learning neural network model into a multi-task network;
[0054] Receive the training images in the water gauge and character detection training dataset through the input layer;
[0055] Extract features of the training image through the backbone network layer to generate a feature map corresponding to the training image;
[0056] Adding a new network branch in the neck network layer, and performing feature fusion on the sub-feature map generated by the trunk network layer through the new network branch to obtain a shallow feature prediction map;
[0057] Performing feature fusion on the feature map generated by the backbone network layer through the neck network layer to obtain a deep feature prediction map;
[0058] Adding a detection head at the detection end layer, and detecting the characters through the newly added detection head according to the shallow feature prediction map;
[0059] According to the deep feature prediction map, the water gauge is detected by using multiple detection heads of the detection end layer;
[0060] The detected water ruler and characters are marked in the training image, the loss is calculated by a loss function, and the deep learning neural network model is updated, wherein the first loss function is used as the loss function for the water ruler part in the deep learning neural network model, and the second loss function is used as the loss function for the character part in the deep learning neural network model.
[0061] Here, the deep learning neural network model can be a yolov5 deep learning neural network model. Yolov5 is a single-stage target detection algorithm, which is mainly composed of four parts: input layer (Input), backbone network layer (Backbone), neck network layer (Neck), and detection layer (Head). Input is the image preprocessing stage, Backbone is the feature extraction stage, Neck is the feature fusion stage, and Head is the stage of predicting image features and generating target frames. The loss function is used to calculate the gap between the predicted value and the actual value.
[0062] Specifically, taking into account the differences in aspect ratio and size between the water ruler and the characters in the water ruler, the network structure of the deep learning neural network model is modified to a multi-task network, one for detecting the water ruler and the other for detecting the characters in the water ruler. In the neck network layer, a new network branch is added for feature fusion of the characters in the water ruler; in the detection end layer, a detection head is added to the branch for character detection in the water ruler; in view of the large aspect ratio of the water ruler target, the first loss function can select the EIoU loss function with faster convergence speed and more accurate positioning; in view of the characteristics of small character targets, the second loss function can select the NWD loss function for improving the small target detection capability.
[0063] In one embodiment, Figure 2 The modified yolov5 neural network structure diagram in this embodiment is as follows: Figure 2As shown, the original image data (image) enters the first Conv module, the second Conv module, the first C3 module, the third Conv module, the second C3 module, the fourth Conv module, the third C3 module, the fifth Conv module, the fourth C3 module and the SPFF module of the backbone network layer (Backbone) in sequence after the input layer (Input), wherein the structure of each Conv module is the same, the structure of each C3 module is also the same, the Conv layer is used for feature extraction, the C3 layer is used for further feature extraction, and the SPPF layer is used to serialize the feature map and calculate multi-scale features; the neck network layer (Neck) includes 5 Conv modules, 5 C3 modules, 3 Upsample modules, and 5 Concat modules. The result of the second C3 module in Backbone is used as the input of the sixth Conv module in Neck. After passing through the first Upsample module, it is fused with the result of the first C3 module in Backbone in the first Concat module. The fused result enters the fifth C3 module and is processed by the detection head 1 of the Head to output the character target frame. The feature map processed by the SPFF module in Backbone is used as the input of the seventh Conv module in Neck. After passing through the second Upsample module, it is fused with the result of the third C3 module in Backbone in the second Concat module. The fused result enters the sixth C3 module, the eighth Conv module, the third Upsample module, and the Backbone The result of the second C3 module in e is fused in the third Concat module. The fused result passes through the seventh C3 module and the ninth Conv module, and is fused with the result of the eighth Conv module in Neck in the fourth Concat module. The fused result passes through the eighth C3 module and the tenth Conv module, and is fused with the result of the seventh Conv module of Neck in the fifth Concat module. The fused result enters the ninth C3 module; the feature map processed by the second C3 module in Backbone is processed by the detection head 2 of the Head and the first water scale target frame is output; the feature map processed by the third C3 module is processed by the detection head 3 and the second water scale target frame is output; the feature map processed by the fourth C3 module is processed by the detection head 4 and the third water scale target frame is output.
[0064] In this way, the network structure of the deep learning neural network model is modified into a multi-task network, which can process multiple tasks at the same time. At the same time, the appropriate feature extraction and loss function are used in each network to reduce the complexity of the algorithm while ensuring the detection accuracy.
[0065] In some specific implementations, a new network branch is added to the neck network layer, and feature fusion is performed on the sub-feature map generated by the trunk network layer through the new network branch to obtain a shallow feature prediction map, including:
[0066] The sub-feature map generated by the main network layer is upsampled by the newly added network branch to obtain a shallower feature map, wherein the sub-feature map is a process feature map generated during the processing of the main network layer;
[0067] The shallower feature map obtained by the newly added network branch and the sub-feature map are feature fused to obtain a shallow feature prediction map.
[0068] Here, since characters are small objects, character features are fused by using shallow features and shallower features.
[0069] Specifically, Figure 2 The modified yolov5 neural network structure diagram in this embodiment is as follows: Figure 2 As shown in the figure, a new network branch is added in Neck, and the result of the second C3 module in Backbone (i.e., the sub-feature map) is used as the input of the sixth Conv module in Neck. After the first Upsample module, it is fused with the result of the first C3 module in Backbone in the first Concat module, and the fused result enters the fifth C3 module; after being processed by the detection head 1 of the Head, the character target box is output.
[0070] In this way, by adding a new network branch in Neck, the detection accuracy of the character E in the water ruler is higher and the effect is better.
[0071] In some specific implementations, the modified deep learning neural network model is trained using the water gauge and character detection training data set to obtain the target detection model, including:
[0072] The deep learning neural network model is trained multiple times using the water gauge and character detection training data sets to update the deep learning neural network model;
[0073] When the loss function of the deep learning neural network model reaches convergence, the target detection model is obtained.
[0074] Here, the loss function reaching convergence may mean that the loss function tends to be stable or the loss function is within a preset function value range.
[0075] Specifically, the deep learning neural network model is trained with the water gauge and character detection training data sets to obtain the loss function, and the deep learning neural network model is updated. The updated deep learning neural network model is trained with the water gauge and character detection training data sets, and then the deep learning neural network model is updated according to the loss function until the loss function converges. At this time, the training of the deep learning neural network model is completed, and the target detection model is obtained.
[0076] In this way, the accuracy of the target detection model can be improved by repeatedly training the deep learning neural network model.
[0077] In some specific implementations, the water level is calculated based on the actual height of the character, the actual total height of the water gauge, the target average height of the character target frame, and the height of the water gauge target frame, including:
[0078] The actual total height of the water ruler above the water is obtained by multiplying the ratio of the actual height of the character to the target average height of the character target frame by the height of the water ruler target frame;
[0079] Subtract the actual total height of the water gauge from the actual total height of the water gauge above the water to obtain the water level;
[0080] The calculation formula is:
[0081] WL=LH÷EH×EL
[0082] Among them, WL is the water level, L is the actual total height of the water gauge, H is the actual height of the character, EH is the target average height of the character target box, and EL is the height of the water gauge target box.
[0083] Specifically, the ratio A between the image and the actual height is obtained through the ratio of the character height in the image to be detected and the actual character height, and then the actual height of the water gauge above the water surface is obtained through the height of the water gauge in the image to be detected and the ratio A, thereby obtaining the water level.
[0084] In this way, the length of the water gauge is calculated using the ratio of the water gauge height and the characters in the image, thus avoiding the problem of excessive error in water level calculation caused by inaccurate detection of the number of characters.
[0085] In some embodiments, the method further comprises:
[0086] Determine whether the water gauge in the image to be detected is perpendicular to the water surface;
[0087] If the water gauge is perpendicular to the water surface, the water level is calculated according to the target average height of the character target frame in the image to be detected and the height of the water gauge target frame;
[0088] If the water gauge is not perpendicular to the water surface, calculate the inclination angle between the water gauge and the water surface;
[0089] Based on the tilt angle, performing tilt correction processing on the ruler target frame and the character target frame;
[0090] The water level is calculated based on the corrected target average height and the height of the water gauge target frame.
[0091] Here, the tilt correction process for the ruler target frame and the character target frame may be performed based on the tilt angle and by using the Hough transform method.
[0092] In this way, the problem of incorrect water level measurement due to the inclination of the water gauge can be solved, thereby improving the accuracy of the water level measurement.
[0093] It should be understood that although Figure 1 and Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 and Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0094] In one embodiment, Figure 3 As shown, a water level recognition device is provided, the device comprising: an acquisition module, a detection module, a screening module, and a calculation module; wherein the acquisition module is used to acquire an image to be detected; wherein the image to be detected comprises a water ruler and characters on the water ruler; the detection module is used to obtain the height of a water ruler target frame corresponding to the water ruler in the image to be detected and the height of a character target frame corresponding to the characters on the water ruler through a target detection model, wherein one image to be detected comprises multiple characters, and one character target frame comprises one character; the screening module is used to calculate the average height and variance of the character target frame in the image to be detected, screen out the character target frame that meets the preset conditions, and obtain the target average height of the character target frame in the image to be detected based on the character target frame that meets the preset conditions, wherein the preset conditions include that the height of the character target frame is within the range of the target average height plus / minus the variance value; the calculation module is used to calculate the water level based on the actual height of the character, the actual total height of the water ruler, the target average height of the character target frame, and the height of the water ruler target frame.
[0095] As a preferred implementation manner, in an embodiment of the present application, the device also includes: a training module, which is specifically used to: obtain a water ruler image, annotate the water ruler and characters in the water ruler in the water ruler image, and obtain a water ruler and character detection training data set; train a modified deep learning neural network model through the water ruler and character detection training data set to obtain the target detection model.
[0096] As a preferred implementation manner, in an embodiment of the present application, the training module is specifically used to: obtain the water gauge image, annotate the water gauge in the water gauge image, and obtain the water gauge detection training data set; obtain a partial water gauge image of the water gauge image; the aspect ratio of the partial water gauge image is less than or equal to a preset value; extract characters in the partial water gauge image, annotate the characters in the partial water gauge image, and obtain the character detection training data set.
[0097] As a preferred implementation mode, in an embodiment of the present application, the training module is specifically used to: modify the network structure of the deep learning neural network model into a multi-task network; receive training images in the water gauge and character detection training data set through the input layer; perform feature extraction on the training image through the backbone network layer to generate a feature map corresponding to the training image; add a network branch to the neck network layer, and perform feature fusion on the sub-feature map generated by the backbone network layer through the added network branch to obtain a shallow feature prediction map; perform feature fusion on the feature map generated by the backbone network layer through the neck network layer to obtain a deep feature prediction map; add a detection head to the detection end layer, and detect characters according to the shallow feature prediction map through the added detection head; detect the water gauge according to the deep feature prediction map through multiple detection heads of the detection end layer; mark the detected water gauge and characters in the training image, calculate the loss through the loss function, and update the deep learning neural network model, wherein the first loss function is used as the loss function for the water gauge part of the deep learning neural network model, and the second loss function is used as the loss function for the character part of the deep learning neural network model.
[0098] As a preferred implementation manner, in an embodiment of the present application, the training module is specifically used to: upsample the sub-feature map generated by the trunk network layer through the newly added network branch to obtain a shallower feature map, wherein the sub-feature map is a process feature map generated during the processing of the trunk network layer; perform feature fusion on the shallower feature map obtained through the newly added network branch and the sub-feature map to obtain a shallow feature prediction map.
[0099] As a preferred implementation manner, in an embodiment of the present application, the training module is specifically used to: train the deep learning neural network model multiple times through water gauge and character detection training data sets, and update the deep learning neural network model; when the loss function of the deep learning neural network model reaches convergence, the target detection model is obtained.
[0100] As a preferred implementation manner, in an embodiment of the present application, the calculation module is specifically used for: calculating the water level based on the actual height of the character, the actual total height of the water ruler, the target average height of the character target frame and the height of the water ruler target frame, including: multiplying the ratio of the actual height of the character to the target average height of the character target frame by the height of the water ruler target frame to obtain the actual total height of the water ruler above the water; subtracting the actual total height of the water ruler above the water from the actual total height of the water ruler to obtain the water level; the calculation formula is: WL=LH÷EH×EL; wherein WL is the water level, L is the actual total height of the water ruler, H is the actual height of the character, EH is the target average height of the character target frame, and EL is the height of the water ruler target frame.
[0101] The specific definition of the water level identification device can be found in the definition of the water level identification method above, which will not be repeated here. Each module in the above-mentioned water level identification device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0102] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a water level identification method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0103] Those skilled in the art will understand that Figure 4The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0104] In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: S1: acquiring an image to be detected; wherein the image to be detected comprises a water ruler and characters on the water ruler; S2: obtaining, through a target detection model, a height of a water ruler target frame corresponding to the water ruler in the image to be detected and a height of a character target frame corresponding to the characters on the water ruler, wherein one image to be detected comprises a plurality of characters, and one character target frame comprises one character; S3: calculating an average height and variance of the character target frames in the image to be detected, screening out character target frames that meet preset conditions, and obtaining a target average height of the character target frames in the image to be detected based on the character target frames that meet the preset conditions, wherein the preset conditions comprise that the height of the character target frame is within the range of the target average height plus / minus the variance value; S4: calculating the water level based on the actual height of the characters, the actual total height of the water ruler, the target average height of the character target frame, and the height of the water ruler target frame.
[0105] In one embodiment, when the processor executes the computer program, the following steps are also implemented: acquiring a water ruler image, annotating the water ruler and characters in the water ruler in the water ruler image, and obtaining a water ruler and character detection training data set; training a modified deep learning neural network model through the water ruler and character detection training data set to obtain the target detection model.
[0106] In one embodiment, when the processor executes the computer program, the following steps are also implemented: acquiring the water ruler image, annotating the water ruler in the water ruler image, and obtaining the water ruler detection training data set; acquiring a partial water ruler image of the water ruler image; the aspect ratio of the partial water ruler image is less than or equal to a preset value; extracting characters from the partial water ruler image, annotating the characters in the partial water ruler image, and obtaining the character detection training data set.
[0107] In one embodiment, the processor further implements the following steps when executing the computer program: the modified deep learning neural network model is trained through the water gauge and character detection training data set to obtain the target detection model, including: modifying the network structure of the deep learning neural network model into a multi-task network; receiving the training image in the water gauge and character detection training data set through the input layer; extracting features of the training image through the backbone network layer to generate a feature map corresponding to the training image; adding a network branch to the neck network layer, and performing feature fusion on the sub-feature map generated by the backbone network layer through the added network branch to obtain a shallow feature prediction map; and The network layer performs feature fusion on the feature map generated by the backbone network layer to obtain a deep feature prediction map; a detection head is added to the detection end layer, and characters are detected through the newly added detection head according to the shallow feature prediction map; the water ruler is detected through multiple detection heads of the detection end layer according to the deep feature prediction map; the detected water ruler and characters are marked in the training image, the loss is calculated through the loss function, and the deep learning neural network model is updated, wherein the first loss function is used as the loss function for the water ruler part in the deep learning neural network model, and the second loss function is used as the loss function for the character part in the deep learning neural network model.
[0108] In one embodiment, when the processor executes the computer program, the following steps are also implemented: the sub-feature map generated by the main network layer is upsampled through the newly added network branch to obtain a shallower feature map, wherein the sub-feature map is a process feature map generated during the processing of the main network layer; the shallower feature map obtained through the newly added network branch and the sub-feature map are feature-fused to obtain a shallow feature prediction map.
[0109] In one embodiment, when the processor executes the computer program, the following steps are also implemented: the deep learning neural network model is trained multiple times using water gauge and character detection training data sets to update the deep learning neural network model; when the loss function of the deep learning neural network model reaches convergence, the target detection model is obtained.
[0110] In one embodiment, when the processor executes the computer program, the following steps are also implemented: multiplying the ratio of the actual height of the character and the target average height of the character target frame by the height of the water ruler target frame to obtain the actual total height of the water ruler above the water; subtracting the actual total height of the water ruler from the actual total height of the water ruler to obtain the water level; the calculation formula is: WL=LH÷EH×EL; wherein WL is the water level, L is the actual total height of the water ruler, H is the actual height of the character, EH is the target average height of the character target frame, and EL is the height of the water ruler target frame.
[0111] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and the following steps are implemented when the computer program is executed by a processor: S1: Acquire an image to be detected; wherein, the image to be detected includes a water ruler and characters on the water ruler; S2: Obtain, through a target detection model, the height of a water ruler target frame corresponding to the water ruler in the image to be detected and the height of a character target frame corresponding to the characters on the water ruler, wherein one image to be detected includes multiple characters, and one character target frame includes one character; S3: Calculate the average height and variance of the character target frames in the image to be detected, filter out character target frames that meet preset conditions, and obtain the target average height of the character target frames in the image to be detected based on the character target frames that meet the preset conditions, wherein the preset conditions include that the height of the character target frame is within the range of the target average height plus / minus the variance value; S4: Calculate the water level based on the actual height of the characters, the actual total height of the water ruler, the target average height of the character target frame, and the height of the water ruler target frame.
[0112] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: acquiring a water ruler image, annotating the water ruler and characters in the water ruler in the water ruler image, and obtaining a water ruler and character detection training data set; training a modified deep learning neural network model using the water ruler and character detection training data set to obtain the target detection model.
[0113] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: acquiring the water ruler image, annotating the water ruler in the water ruler image, and obtaining the water ruler detection training data set; acquiring a partial water ruler image of the water ruler image; the aspect ratio of the partial water ruler image is less than or equal to a preset value; extracting characters in the partial water ruler image, annotating the characters in the partial water ruler image, and obtaining the character detection training data set.
[0114] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: the modified deep learning neural network model is trained through the water gauge and character detection training data set to obtain the target detection model, including: modifying the network structure of the deep learning neural network model into a multi-task network; receiving the training images in the water gauge and character detection training data set through the input layer; extracting features of the training images through the backbone network layer to generate a feature map corresponding to the training images; adding a network branch to the neck network layer, and performing feature fusion on the sub-feature map generated by the backbone network layer through the added network branch to obtain a shallow feature prediction map; and The outer network layer performs feature fusion on the feature map generated by the backbone network layer to obtain a deep feature prediction map; a detection head is added to the detection end layer, and characters are detected through the newly added detection head according to the shallow feature prediction map; the water ruler is detected through multiple detection heads of the detection end layer according to the deep feature prediction map; the detected water ruler and characters are marked in the training image, the loss is calculated through the loss function, and the deep learning neural network model is updated, wherein the first loss function is used as the loss function for the water ruler part in the deep learning neural network model, and the second loss function is used as the loss function for the character part in the deep learning neural network model.
[0115] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: adding a new network branch to the neck network layer, and performing feature fusion on the sub-feature map generated by the trunk network layer through the newly added network branch to obtain a shallow feature prediction map, including: upsampling the sub-feature map generated by the trunk network layer through the newly added network branch to obtain a shallower feature map, wherein the sub-feature map is a process feature map generated during the processing of the trunk network layer; performing feature fusion on the shallower feature map obtained by the newly added network branch and the sub-feature map to obtain a shallow feature prediction map.
[0116] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: the deep learning neural network model is trained multiple times using water gauge and character detection training data sets to update the deep learning neural network model; when the loss function of the deep learning neural network model reaches convergence, the target detection model is obtained.
[0117] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: multiplying the ratio of the actual height of the character and the target average height of the character target frame by the height of the water ruler target frame to obtain the actual total height of the water ruler above the water; subtracting the actual total height of the water ruler from the actual total height of the water ruler to obtain the water level; the calculation formula is: WL=LH÷EH×EL; wherein WL is the water level, L is the actual total height of the water ruler, H is the actual height of the character, EH is the target average height of the character target frame, and EL is the height of the water ruler target frame.
[0118] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0119] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0120] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A water level identification method, characterized in that: The method comprises: Acquire an image to be detected; wherein the image to be detected includes a water ruler and characters on the water ruler; Obtaining the height of the water ruler target frame corresponding to the water ruler in the image to be detected and the height of the character target frame corresponding to the character on the water ruler through the target detection model, wherein one image to be detected includes multiple characters and one character target frame includes one character; Calculating the average height and variance of the character target frames in the image to be detected, screening out the character target frames that meet the preset conditions, and obtaining the target average height of the character target frames in the image to be detected according to the character target frames that meet the preset conditions, wherein the preset conditions include that the height of the character target frame is within the range of the target average height plus / minus the variance value; The water level is calculated based on the actual height of the character, the actual total height of the water gauge, the target average height of the character target frame and the height of the water gauge target frame.
2. The water level identification method according to claim 1, characterized in that: Before acquiring the image to be detected, the method further includes: Acquire a water ruler image, and annotate the water ruler and characters in the water ruler in the water ruler image to obtain a water ruler and character detection training data set; The modified deep learning neural network model is trained using the water gauge and character detection training data set to obtain the target detection model.
3. The water level identification method according to claim 2, characterized in that: The step of acquiring a water ruler image, marking the water ruler and characters in the water ruler in the water ruler image, and obtaining a water ruler and character detection training data set includes: Acquire the water gauge image, mark the water gauge in the water gauge image, and obtain the water gauge detection training data set; acquire a partial water gauge image of the water gauge image; the aspect ratio of the partial water gauge image is less than or equal to a preset value; Characters in the partial water gauge image are extracted, and the characters in the partial water gauge image are labeled to obtain the character detection training data set.
4. The water level identification method according to claim 2, characterized in that: The modified deep learning neural network model is trained by using the water gauge and character detection training data set to obtain the target detection model, including: modifying the network structure of the deep learning neural network model into a multi-task network; Receive the training images in the water gauge and character detection training dataset through the input layer; Extract features of the training image through the backbone network layer to generate a feature map corresponding to the training image; add a network branch to the neck network layer, and perform feature fusion on the sub-feature map generated by the backbone network layer through the added network branch to obtain a shallow feature prediction map; Performing feature fusion on the feature map generated by the backbone network layer through the neck network layer to obtain a deep feature prediction map; Adding a detection head at the detection end layer, and detecting the characters through the newly added detection head according to the shallow feature prediction map; According to the deep feature prediction map, the water gauge is detected by using multiple detection heads of the detection end layer; The detected water ruler and characters are marked in the training image, the loss is calculated by a loss function, and the deep learning neural network model is updated, wherein the first loss function is used as the loss function for the water ruler part in the deep learning neural network model, and the second loss function is used as the loss function for the character part in the deep learning neural network model.
5. The water level identification method according to claim 4, characterized in that: The adding of a new network branch in the neck network layer and performing feature fusion on the sub-feature map generated by the trunk network layer through the new network branch to obtain a shallow feature prediction map include: The sub-feature map generated by the main network layer is upsampled by the newly added network branch to obtain a shallower feature map, wherein the sub-feature map is a process feature map generated during the processing of the main network layer; The shallower feature map obtained by the newly added network branch and the sub-feature map are feature fused to obtain a shallow feature prediction map.
6. The water level identification method according to claim 4, characterized in that: The modified deep learning neural network model is trained by the water gauge and character detection training data set to obtain the target detection model, including: training the deep learning neural network model multiple times by the water gauge and character detection training data set to update the deep learning neural network model; When the loss function of the deep learning neural network model reaches convergence, the target detection model is obtained.
7. The water level identification method according to claim 6, characterized in that: The step of calculating the water level according to the actual height of the character, the actual total height of the water gauge, the target average height of the character target frame and the height of the water gauge target frame comprises: The actual total height of the water ruler above the water is obtained by multiplying the ratio of the actual height of the character to the target average height of the character target frame by the height of the water ruler target frame; Subtract the actual total height of the water gauge from the actual total height of the water gauge above the water to obtain the water level; The calculation formula is: WL=LH÷EH×EL Among them, WL is the water level, L is the actual total height of the water gauge, H is the actual height of the character, EH is the target average height of the character target box, and EL is the height of the water gauge target box.
8. A water level identification device, characterized in that: The device comprises: an acquisition module, a detection module, a screening module, and a calculation module; wherein, The acquisition module is used to acquire an image to be detected; wherein the image to be detected includes a water ruler and characters on the water ruler; the detection module is used to obtain the height of a water ruler target frame corresponding to the water ruler in the image to be detected and the height of a character target frame corresponding to the characters on the water ruler through a target detection model, wherein one image to be detected includes multiple characters, and one character target frame includes one character; The screening module is used to calculate the average height and variance of the character target frames in the image to be detected, screen out the character target frames that meet the preset conditions, and obtain the target average height of the character target frames in the image to be detected based on the character target frames that meet the preset conditions, wherein the preset conditions include that the height of the character target frame is within the range of the target average height plus / minus the variance value; The calculation module is used to calculate the water level according to the actual height of the character, the actual total height of the water gauge, the target average height of the character target frame and the height of the water gauge target frame.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Water gauge water level machine vision detection method and device with free shooting visual angle
CN115578695A
Target detection method and device based on YOLOv5 improvement, and training method
CN116310899A
Ship water gauge reading method and system based on computer vision
CN116935369A
Water level identification method and system in outdoor complex scene
CN117095408A
Target detection method and device, equipment and storage medium
CN117593516A
Cited By
Muddy water level height monitoring system and method and medium
CN119826923A
A monitoring system, method and medium for mud water level
CN119826923B
