A water depth detection method and system based on target detection model
Through the water depth detection method based on the target detection model, the human body part detection model and social media images are used to calculate the depth of accumulated water, which solves the problems of low water depth detection accuracy and high cost in traditional methods, and realizes high-precision and low-cost water depth detection to support flood disaster management.
Patent Information
- Application Number
- CN202310129884.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-01
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2043-02-01
AI Technical Summary
Existing technologies have low water depth detection accuracy in flood detection. Traditional methods are costly and require a lot of installation work, and machine learning methods can only roughly detect the water level range.
A water depth detection method based on the target detection model is adopted. The feature information in the image is obtained through the human body part detection model. The water depth is calculated by combining the actual length of the human body part and the height of the bounding box. The human body part detection model is trained using the YOLOv5 algorithm, and social media images are used for real-time and low-cost detection.
It improves the precision and accuracy of water depth detection, reduces the false detection rate, realizes fast and low-cost water depth detection, and supports flood disaster management and waterlogging management.
Smart Images

Figure CN116129267B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of water accumulation detection, and in particular to a water depth detection method and system based on a target detection model. Background Art
[0002] When a flood occurs, rapid response based on real-time information such as its location and severity is crucial for mitigating losses. Currently, traditional waterlogging detection relies on hardware that directly contacts the water, such as water level sensors. While these methods can accurately monitor water levels, they require extensive equipment installation and are costly.
[0003] With the development of computer and image processing technologies, machine learning is gradually being applied to flood detection and flood severity assessment. In the context of flood detection, Pereira et al. used deep learning techniques to classify images. Using convolutional neural network architectures (EndseNet and EfficientNet models), they classified social media images into three categories: no flooding, water levels below 1 meter, and water levels above 1 meter. However, this method only roughly detected the water level, providing a water depth range rather than the actual depth, resulting in low detection accuracy. Summary of the Invention
[0004] The present invention provides a water depth detection method and system based on a target detection model to solve the technical problem of how to improve the accuracy of water depth detection.
[0005] In order to solve the above technical problems, an embodiment of the present invention provides a water depth detection method based on a target detection model, comprising:
[0006] Acquire an image to be detected; wherein the image to be detected is an image containing a human body and accumulated water;
[0007] Inputting the image to be detected into a pre-trained human body part detection model to obtain a feature image; the feature image includes detected bounding box information and detected human body part information; the detected human body part information includes the category of the human body part and the actual length corresponding to each human body part; the bounding box information includes the pixel height of the bounding box corresponding to each human body part;
[0008] The depth of the accumulated water in the image to be detected is calculated based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box.
[0009] As a preferred solution, the depth of the accumulated water in the image to be detected is calculated based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box, specifically:
[0010] When the feature image contains only one person, the depth of the water in the image to be detected is calculated based on the actual lengths of the first and second categories and the pixel height of the bounding box, in combination with a preset algorithm; wherein the first category is the lowest human body part detected, and the second category is the adjacent category detected to the first category;
[0011] When the feature image contains multiple people, each of the first categories is matched with the corresponding second category based on the difference in the minimum value of the bounding box on the x-axis; based on the matched first and second categories, combined with the preset algorithm, the water depth data corresponding to each person is calculated separately, and the maximum water depth data is used as the accumulated water depth.
[0012] As a preferred solution, the preset algorithm is specifically:
[0013] The categories of human body parts include calves, thighs, shoulders, and heads;
[0014] The water depth is calculated according to the following formula:
[0015]
[0016]
[0017]
[0018]
[0019]
[0020]
[0021] Among them, Depth ct Depth is the actual water depth when the feature image contains the calf and thigh. cs is the actual water depth when the feature image contains the calf and shoulder but not the thigh, ch Depth is the actual water depth when the feature image includes thighs and head but not calves and shoulders. ts Depth is the actual water depth when the feature image includes thighs and shoulders but not calves. th Depth is the actual water depth when the feature image includes thighs and head but not calves and shoulders. shis the actual water depth when the feature image includes shoulders and head but not calves and thighs, h ac is the actual length of the calf, h at is the actual length of the thigh, h as is the actual length of the shoulder, h ah is the actual length of the head, λ c is the correction coefficient of the thigh, λ s is the correction coefficient for the shoulder, λ h is the correction coefficient of the head, h c is the pixel height of the bounding box corresponding to the calf, h t is the pixel height of the bounding box corresponding to the thigh, h s is the pixel height of the bounding box corresponding to the shoulder, h h is the pixel height of the bounding box corresponding to the head.
[0022] As a preferred solution, the training process of the human body part detection model includes:
[0023] Obtaining a training set; wherein the training set is a plurality of images containing human bodies and accumulated water;
[0024] According to the training set, a basic detection model is constructed based on the YOLOv5 algorithm, wherein the basic detection model includes a focus structure, a convolution block, a cross-stage part, and a residual block; wherein the focus structure is used to reduce the size of the image; and the convolution block includes a convolution layer, a batch normalization layer, and a leaky ReLU layer;
[0025] The basic detection model is trained using the training set. The loss function corresponding to each training is calculated based on the output of the basic detection model, and the model parameters of the basic detection model are updated through the back propagation algorithm until the basic detection model meets the preset convergence conditions, thereby obtaining the trained human body part detection model.
[0026] As a preferred solution, the loss function of the basic detection model includes bounding box loss, confidence loss and class loss; the bounding box loss adopts the CloU-loss function.
[0027] As a preferred solution, the acquisition of the training set is specifically as follows:
[0028] On social media, the YOLOv3 algorithm was used to search for images containing human bodies and water accumulation.
[0029] Delete images with the same MD5 value from the searched images to obtain the first data set;
[0030] Label the calves, thighs, shoulders, and heads in all images in the first dataset;
[0031] The labeled images are enhanced and expanded to obtain the training set; wherein the enhancement processing includes horizontal flipping processing, grayscale processing, and brightness processing.
[0032] Accordingly, an embodiment of the present invention further provides a water depth detection system based on a target detection model, comprising an image acquisition module, a feature extraction module and a water depth detection module; wherein,
[0033] The image acquisition module is used to acquire an image to be detected; wherein the image to be detected is an image containing a human body and accumulated water;
[0034] The feature extraction module is used to input the image to be detected into a pre-trained human body part detection model to obtain a feature image; the feature image includes detected bounding box information and detected human body part information; the detected human body part information includes the category of the human body part and the actual length corresponding to each human body part; the bounding box information includes the pixel height of the bounding box corresponding to each human body part;
[0035] The water depth detection module is used to calculate the depth of the accumulated water in the image to be detected based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box.
[0036] As a preferred solution, the water depth detection module calculates the depth of the accumulated water in the image to be detected based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box, specifically:
[0037] When the feature image contains only one person, the water depth detection module calculates the depth of the water in the image to be detected based on the actual lengths of the first and second categories and the pixel height of the bounding box, combined with a preset algorithm; wherein the first category is the lowest human body part detected, and the second category is the adjacent category detected to the first category;
[0038] When the feature image contains multiple people, the water depth detection module matches each first category with the corresponding second category based on the difference in the minimum value of the bounding box on the x-axis; based on the matched first and second categories, combined with the preset algorithm, the water depth data corresponding to each person is calculated respectively, and the maximum water depth data is used as the accumulated water depth.
[0039] As a preferred solution, the preset algorithm is specifically:
[0040] The categories of human body parts include calves, thighs, shoulders, and heads;
[0041] The water depth is calculated according to the following formula:
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048] Among them, Depth ct Depth is the actual water depth when the feature image contains the calf and thigh. cs is the actual water depth when the feature image contains the calf and shoulder but not the thigh, ch Depth is the actual water depth when the feature image includes thighs and head but not calves and shoulders. ts Depth is the actual water depth when the feature image includes thighs and shoulders but not calves. th Depth is the actual water depth when the feature image includes thighs and head but not calves and shoulders. sh is the actual water depth when the feature image includes shoulders and head but not calves and thighs, h ac is the actual length of the calf, h at is the actual length of the thigh, h as is the actual length of the shoulder, h ah is the actual length of the head, λ c is the correction coefficient of the thigh, λ s is the correction coefficient for the shoulder, λ h is the correction coefficient of the head, h c is the pixel height of the bounding box corresponding to the calf, h t is the pixel height of the bounding box corresponding to the thigh, h s is the pixel height of the bounding box corresponding to the shoulder, h h is the pixel height of the bounding box corresponding to the head.
[0049] As a preferred solution, the training process of the human body part detection model includes:
[0050] Obtaining a training set; wherein the training set is a plurality of images containing human bodies and accumulated water;
[0051] According to the training set, a basic detection model is constructed based on the YOLOv5 algorithm, wherein the basic detection model includes a focus structure, a convolution block, a cross-stage part, and a residual block; wherein the focus structure is used to reduce the size of the image; and the convolution block includes a convolution layer, a batch normalization layer, and a leaky ReLU layer;
[0052] The basic detection model is trained using the training set. The loss function corresponding to each training is calculated based on the output of the basic detection model, and the model parameters of the basic detection model are updated through the back propagation algorithm until the basic detection model meets the preset convergence conditions, thereby obtaining the trained human body part detection model.
[0053] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0054] Embodiments of the present invention provide a water depth detection method and system based on a target detection model. The water depth detection method comprises: obtaining an image to be detected; wherein the image to be detected is an image containing a human body and accumulated water; inputting the image to be detected into a pre-trained human body part detection model to obtain a feature image; the feature image includes detected bounding box information and human body part information; the detected human body part information includes the human body part category and the actual length corresponding to each human body part; the bounding box information includes the pixel height of the bounding box corresponding to the human body part; and calculating the depth of the accumulated water in the image to be detected based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box. The present invention obtains a feature image through the human body part detection model, calculates the depth of the accumulated water based on the human body part detected in the feature image, its actual length, and the pixel height of the bounding box. Compared with existing technical solutions that roughly estimate the water depth range (for example, determining whether the water depth is above or below 1 meter, or determining which water level is higher in two images), the present invention has higher detection precision and accuracy.
[0055] Furthermore, the feature map is divided according to the number of people in it. When there is only one person in the feature map, the actual lengths of the first and second categories and the pixel heights of the bounding boxes are used in combination with a preset algorithm for calculation. When the feature map contains multiple people, the difference in the minimum values of the bounding boxes on the x-axis is considered to match each of the first categories with the corresponding second category, and then the depth of the accumulated water is calculated, thereby avoiding erroneous detection results caused by matching errors between the first and second categories when there are multiple people, and effectively reducing the false detection rate.
[0056] Furthermore, the present invention also provides the specific content of the preset algorithm. The categories of human body parts include calves, thighs, shoulders and heads, and the actual water depth is calculated based on the parts detected in the feature image and the ratio between the parts, providing a new idea for water depth detection, which can further improve the accuracy of detection.
[0057] Furthermore, considering the need to respond quickly using real-time information such as the depth of the flood in situations such as floods, searching for pictures containing human bodies and floods on social media can use social media to provide real-time, low-cost flood or waterlogging event information, thereby achieving rapid detection and rapid response, improving the real-time nature of detection, and providing effective support for effective flood disaster management, waterlogging management, etc.; the calves, thighs, shoulders and heads in all images in the first dataset are annotated, and then horizontal flipping, grayscale processing, brightness processing and expansion processing are performed. The processing process is simple and does not require pixel-scale annotation, effectively reducing computing and processing costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 : A flow chart of an embodiment of a water depth detection method provided by the present invention based on a target detection model.
[0059] Figure 2 : A flow chart of another embodiment of a water depth detection method provided by the present invention based on a target detection model.
[0060] Figure 3 : A schematic diagram of an embodiment of the training set preprocessing method provided by the present invention.
[0061] Figure 4 : A schematic diagram of an embodiment of the model network architecture provided by the present invention.
[0062] Figure 5 : A structural diagram of an embodiment of a water depth detection system provided by the present invention based on a target detection model. DETAILED DESCRIPTION
[0063] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0064] Embodiment one:
[0065] Please refer to Figure 1 and Figure 2 , Figure 1The present invention provides a method for water depth detection based on a target detection model, including steps S1 to S3, wherein:
[0066] Step S1, obtaining an image to be detected; wherein the image to be detected is an image containing a human body and accumulated water.
[0067] In this embodiment, it is first necessary to obtain the image to be detected, which can be obtained from channels such as the official website of social media, mini-programs, etc. As an example of this embodiment, for disasters such as floods, the evolution process of the flood has a certain complexity, which will make it difficult to model it in real time. The existing technology generally collects real-time data through water level sensors or automatic water level gauges. Automatic water level gauges are usually installed every few dozen kilometers along the river channel, and several may be installed each time, which leads to high manpower and material costs; and during floods, limited real-time water level information is difficult to use for flood mapping. Therefore, considering these problems, social media has great advantages in providing real-time and low-cost flood event information. This embodiment can obtain images to be detected from channels such as the official website, mini-programs or public accounts of major social media for rapid detection of water depth and subsequent timely response.
[0068] At the same time, social media can also be searched and processed to obtain a training set, which is used to build and train the human body part (target) detection model in step S2. The specific method for obtaining the training set is as follows:
[0069] On social media, 2,620 images were first retrieved through crawling, and then the YOLOv3 algorithm was used to traverse and search for pictures containing human bodies and accumulated water. Specifically, the YOLOv3 algorithm was pre-trained on a large dataset. At the same time, the traversal algorithm was implemented based on Python to select images containing humans and floods.
[0070] The MD5 (Message-Digest) values of images with similar image IDs were calculated using Python, and images with the same MD5 values were deleted from the searched images to obtain the first data set. Finally, a total of 1,266 images were retained.
[0071] In this embodiment, before calculating the depth of water accumulation, it is necessary to correctly detect body parts and accurately estimate the water depth based on the ratio between different body parts. Therefore, the calves, thighs, shoulders and heads in all images in the first dataset are annotated, such as Figure 3 As shown, the human body is composed of the calf, thigh, shoulder and head from bottom to top. Figure 3 a. Annotate all images in the first dataset. The annotation results are mainly divided into three categories: Figure 3b (including calves, thighs, shoulders and head), Figure 3 c (thighs, shoulders, and head) and Figure 3 d (shoulders and head).
[0072] Since the first dataset contains only 1,266 images, it is considered a relatively small dataset. Therefore, in order to ensure the complexity of the background dataset, the annotated images are enhanced and expanded to obtain the training set, which can prevent overfitting and ensure high robustness. The enhancement processing includes horizontal flipping, grayscale processing, and brightness processing. The training set obtained after the above preprocessing does not require pixel-scale annotation of objects, which reduces a large amount of manual annotation workload and effectively reduces computational costs.
[0073] Step S2: input the image to be detected into a pre-trained human body part detection model to obtain a feature image; the feature image includes the detected bounding box information and the detected human body part information; the detected human body part information includes the category of the human body part and the actual length corresponding to each human body part; the bounding box information includes the pixel height of the bounding box corresponding to each human body part.
[0074] Furthermore, the construction and training process of the human body part (target) detection model includes: constructing a basic detection model based on the YOLOv5 algorithm and convolutional neural network (CNN) according to the training set, wherein the basic detection model mainly includes a focus structure, a convolution block, a cross-stage part (CSP) and a residual block; wherein the focus structure is used to reduce the size of the image; the convolution block includes a convolution layer, a batch normalization layer and a leaky ReLU layer;
[0075] The basic detection model is trained using the training set. The loss function corresponding to each training is calculated based on the output of the basic detection model, and the model parameters of the basic detection model are updated through the back propagation algorithm until the basic detection model meets the preset convergence conditions (for example, finding better weights and biases), thereby obtaining the trained human body part detection model.
[0076] The network architecture of the basic detection model of this embodiment can be referred to Figure 4 , which mainly includes focal structure, convolutional block, cross-stage part (CSP) and residual block. Figure 4 In the figure, the dotted box in the upper left corner consists of the focal structure, convolutional layers, and cross-stage partial_1. The dotted box in the lower left corner is a spatial pyramid pooling (SPP) structure, which can obtain different important contextual features to expand the receptive field. The dotted box on the right is the neck of the network, which mainly uses PANet to achieve better prediction feature fusion.
[0077] The focus structure is used to increase the channel data before convolution extraction of features from the backbone network to achieve the effect of reducing the image.
[0078] The convolution block consists of three parts, including a convolution layer, a batch normalization (BN) layer, and a leaky ReLU layer. In the convolution layer, multiple convolution kernels of size 3×3 or 1×1 are used to generate feature maps, and convolution operations are performed according to the step size. Compared with traditional neural networks, the computational cost can be reduced. The BN layer after each convolution layer can reduce the amplitude of data changes, speed up learning, and prevent overfitting. The data after the convolution layer and the BN layer is used as the input data of the activation function. In order to handle the complexity of the image, the nonlinear activation functions of the prior art mainly include sigmoid, tanh, and ReLU functions. However, the sigmoid and tanh functions are associated with gradient disappearance, which may lead to training failure, and when the input is negative, the neuron nodes of the ReLU function will disappear. Taking these problems into consideration, this embodiment adopts the Leaky ReLU function to give a non-zero slope to all negative values to solve the above-mentioned problems such as neuron death.
[0079] The cross-stage part (CSP) divides the feature map of the input layer into two parts, one of which undergoes a series of operations, such as convolution, and the other remains unchanged. The two parts are then merged through a cross-stage hierarchy, which can solve problems such as learning ability, computational bottlenecks, and memory. At the same time, there are two types of cross-stage parts (CSP) in the network structure of this embodiment, one contains a residual block, namely Cross Stage Partial_1, and the other does not contain a residual block, namely CrossStage Partial_2. The residual block can ensure that when the network has a certain depth, the time consumption is reduced, and is connected in the form of a short connection as shown in the figure.
[0080] According to the network architecture of this embodiment, the final output is feature maps of three scales, namely y1, y2 and y3, as shown in Figure 4 As shown, it is divided into S×S grids, which are responsible for predicting bounding boxes, classes, and objects respectively. The training process is actually a process of finding the minimum loss value, which specifically includes box loss, object loss, and category loss. The predicted value is made closer to the ground truth through training. Furthermore, the loss function of the basic detection model includes bounding box loss, confidence loss, and class loss. Since the boundary loss only considers the center point, width, and height of the bounding box, and does not consider its integrity, the bounding box loss described in this embodiment adopts the CloU-loss function.
[0081] The feature image obtained in this embodiment identifies the categories of human body parts, including the calf, thigh, shoulder and head, as well as the actual lengths corresponding to the detected human body parts. Each detected human body part is marked with a bounding box, which has the advantages of rapid detection and short response time.
[0082] Step S3: Calculate the depth of the water in the image to be detected based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box.
[0083] This embodiment divides the image into groups based on the number of people in the feature image. When the feature image contains only one person, the depth of the water accumulation in the image to be detected is calculated based on the actual lengths of the first and second categories and the pixel height of the bounding box, in combination with a preset algorithm. The first category (Class "a") is the lowest human body part detected, and the second category (Class "b") is the adjacent category detected to the first category.
[0084] When the feature image contains multiple people, the number of bounding boxes detected in Class "a" and Class "b" will be greater than 1. In order to ensure that the selected Class "a" and Class "b" prediction boxes are from the same person, the difference in the minimum value of the predicted bounding boxes on the x-axis (x min ), where the image coordinate system is based on the upper left corner of the image as the coordinate origin, the horizontal direction is the x-axis, and the vertical direction is the y-axis. For each first category, the bounding box with the smallest difference in the corresponding second category, i.e., Class "b" is matched; based on the matched first and second categories, combined with the preset algorithm, the water depth data corresponding to each person is calculated, and the maximum water depth data is used as the water depth. If only class "a" is detected, the water depth range based on class "a" is returned (for example, if only class "a" is detected as the calf, but no other categories are detected, the actual water depth is the length range of "calf" (0-39.5 cm). If neither class exists, the output is undefined.
[0085] The preset algorithm is specifically:
[0086] The categories of human body parts include calves, thighs, shoulders, and heads;
[0087] The water depth is calculated according to the following formula:
[0088]
[0089]
[0090]
[0091]
[0092]
[0093]
[0094] Among them, Depth ct Depth is the actual water depth when the feature image contains the calf and thigh. cs is the actual water depth when the feature image contains the calf and shoulder but not the thigh, ch Depth is the actual water depth when the feature image includes thighs and head but not calves and shoulders. ts Depth is the actual water depth when the feature image includes thighs and shoulders but not calves. th Depth is the actual water depth when the feature image includes thighs and head but not calves and shoulders. sh is the actual water depth when the feature image includes shoulders and head but not calves and thighs, h ac is the actual length of the calf, h at is the actual length of the thigh, h as is the actual length of the shoulder, h ah is the actual length of the head, λ c is the correction coefficient of the thigh (preferably 0.8 in this embodiment), λ s is the correction coefficient for the shoulder (preferably 1.1 in this embodiment), λ h is the correction coefficient of the head (preferably 0.9 in this embodiment), h c is the pixel height of the bounding box corresponding to the calf, h t is the pixel height of the bounding box corresponding to the thigh, h s is the pixel height of the bounding box corresponding to the shoulder, h his the pixel height of the bounding box corresponding to the head. In this embodiment, the categories of human body parts include calves, thighs, shoulders and head, and the actual water depth is calculated based on the parts detected in the feature image and the ratio between the parts, which provides a new idea for water depth detection. Compared with the technical solutions of the prior art for roughly estimating the water level, such as a technical solution for training a water level estimation model including detecting four water level categories of ankles, knees, hips and chests, or a technical solution for dividing the image to be detected into three categories of no flooding, water level below 1 meter and water level above 1 meter, the embodiment of the present application has higher detection accuracy; in addition to detecting the water level range (including calves, thighs, shoulders and head), it can also automatically calculate the actual water depth, with an error range of centimeters; and another technical solution of the prior art uses Mask R-CNN uses bounding boxes to detect the human body, OpenPose is used to detect eight key parts of the human body, and Deeplabv3+ is used to train a water level classifier. One of four levels is returned as the severity of the flood. This application designs a simpler framework that is simple and easy to operate and has relatively higher accuracy. At the same time, the technical solution of this embodiment can be used to detect the depth of urban flooding in social media images and produce corresponding flood maps, which can support the urban flood prevention and control work of intelligent urban management.
[0095] Accordingly, refer to Figure 5 The embodiment of the present invention further provides a water depth detection system based on a target detection model, comprising an image acquisition module 101, a feature extraction module 102 and a water depth detection module 103; wherein,
[0096] The image acquisition module 101 is used to acquire an image to be detected; wherein the image to be detected is an image containing a human body and accumulated water;
[0097] The feature extraction module 102 is used to input the image to be detected into a pre-trained human body part detection model to obtain a feature image; the feature image includes detected bounding box information and detected human body part information; the detected human body part information includes the category of the human body part and the actual length corresponding to each human body part; the bounding box information includes the pixel height of the bounding box corresponding to each human body part;
[0098] The water depth detection module 103 is configured to calculate the depth of the accumulated water in the image to be detected based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box.
[0099] As a preferred solution, the water depth detection module 103 calculates the depth of the water in the image to be detected based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box, specifically:
[0100] When the feature image contains only one person, the water depth detection module 103 calculates the depth of the water in the image to be detected based on the actual lengths of the first and second categories and the pixel height of the bounding box, in combination with a preset algorithm; wherein the first category is the lowest human body part detected, and the second category is the adjacent category detected to the first category;
[0101] When the feature image contains multiple people, the water depth detection module 103 matches each first category with the corresponding second category based on the difference in the minimum value of the bounding box on the x-axis; based on the matched first category and second category, combined with the preset algorithm, the water depth data corresponding to each person is calculated respectively, and the maximum water depth data is used as the accumulated water depth.
[0102] As a preferred solution, the preset algorithm is specifically:
[0103] The categories of human body parts include calves, thighs, shoulders, and heads;
[0104] The water depth is calculated according to the following formula:
[0105]
[0106]
[0107]
[0108]
[0109]
[0110]
[0111] Among them, Depth ct Depth is the actual water depth when the feature image contains the calf and thigh. cs is the actual water depth when the feature image contains the calf and shoulder but not the thigh, ch Depth is the actual water depth when the feature image includes thighs and head but not calves and shoulders. ts Depth is the actual water depth when the feature image includes thighs and shoulders but not calves. th Depth is the actual water depth when the feature image includes thighs and head but not calves and shoulders. sh is the actual water depth when the feature image includes shoulders and head but not calves and thighs, h ac is the actual length of the calf, h atis the actual length of the thigh, h as is the actual length of the shoulder, h ah is the actual length of the head, λ c is the correction coefficient of the thigh, λ s is the correction coefficient for the shoulder, λ h is the correction coefficient of the head, h c is the pixel height of the bounding box corresponding to the calf, h t is the pixel height of the bounding box corresponding to the thigh, h s is the pixel height of the bounding box corresponding to the shoulder, h h is the pixel height of the bounding box corresponding to the head.
[0112] As a preferred solution, the training process of the human body part detection model includes:
[0113] Obtaining a training set; wherein the training set is a plurality of images containing human bodies and accumulated water;
[0114] According to the training set, a basic detection model is constructed based on the YOLOv5 algorithm, wherein the basic detection model includes a focus structure, a convolution block, a cross-stage part, and a residual block; wherein the focus structure is used to reduce the size of the image; and the convolution block includes a convolution layer, a batch normalization layer, and a leaky ReLU layer;
[0115] The basic detection model is trained using the training set. The loss function corresponding to each training is calculated based on the output of the basic detection model, and the model parameters of the basic detection model are updated through the back propagation algorithm until the basic detection model meets the preset convergence conditions, thereby obtaining the trained human body part detection model.
[0116] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0117] Embodiments of the present invention provide a water depth detection method and system based on a target detection model. The water depth detection method comprises: obtaining an image to be detected; wherein the image to be detected is an image containing a human body and accumulated water; inputting the image to be detected into a pre-trained human body part detection model to obtain a feature image; the feature image includes detected bounding box information and human body part information; the detected human body part information includes the human body part category and the actual length corresponding to each human body part; the bounding box information includes the pixel height of the bounding box corresponding to each human body part; and calculating the depth of the accumulated water in the image to be detected based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box. The present invention obtains a feature image through the human body part detection model, calculates the depth of the accumulated water based on the human body parts detected in the feature image, their actual lengths, and the pixel heights of the bounding boxes. Compared with existing technical solutions that roughly estimate the water depth range (for example, determining whether the water depth is above or below 1 meter, or determining which water level is higher in two images), the present invention has higher detection precision and accuracy.
[0118] Furthermore, the feature map is divided according to the number of people in it. When there is only one person in the feature map, the actual lengths of the first and second categories and the pixel heights of the bounding boxes are used in combination with a preset algorithm for calculation. When the feature map contains multiple people, the difference in the minimum values of the bounding boxes on the x-axis is considered to match each of the first categories with the corresponding second category, and then the depth of the accumulated water is calculated, thereby avoiding erroneous detection results caused by matching errors between the first and second categories when there are multiple people, and effectively reducing the false detection rate.
[0119] Furthermore, the present invention also provides the specific content of the preset algorithm, and the categories of human body parts include calves, thighs, shoulders and heads, and then the actual water depth is calculated based on the parts detected in the feature image and the ratio between the parts, providing a new idea for water depth detection, which can further improve the accuracy of detection.
[0120] Furthermore, considering the need to respond quickly using real-time information such as the depth of the flood in situations such as floods, searching for pictures containing human bodies and floods on social media can use social media to provide real-time, low-cost flood or waterlogging event information, thereby achieving rapid detection and rapid response, improving the real-time nature of detection, and providing effective support for effective flood disaster management, waterlogging management, etc.; the calves, thighs, shoulders and heads in all images in the first dataset are annotated, and then horizontal flipping, grayscale processing, brightness processing and expansion processing are performed. The processing process is simple and does not require pixel-scale annotation, effectively reducing computing and processing costs.
[0121] The specific embodiments described above further illustrate the objectives, technical solutions, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A water depth detection method based on a target detection model, characterized in that: include: Acquire an image to be detected; wherein the image to be detected is an image containing a human body and accumulated water; Inputting the image to be detected into a pre-trained human body part detection model to obtain a feature image; the feature image includes detected bounding box information and detected human body part information; the detected human body part information includes the category of the human body part and the actual length corresponding to each human body part; the bounding box information includes the pixel height of the bounding box corresponding to each human body part; Calculating the depth of the accumulated water in the image to be detected based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box; The depth of the accumulated water in the image to be detected is calculated based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box, specifically: When the feature image contains only one person, the depth of the water in the image to be detected is calculated based on the actual lengths of the first and second categories and the pixel height of the bounding box, in combination with a preset algorithm; wherein the first category is the lowest human body part detected, and the second category is the adjacent category detected to the first category; When the feature image contains multiple people, each of the first categories is matched with the corresponding second category based on the difference in the minimum value of the bounding box on the x-axis; based on the matched first and second categories, combined with the preset algorithm, the water depth data corresponding to each person is calculated separately, and the maximum water depth data is used as the accumulated water depth.
2. The water depth detection method based on the target detection model according to claim 1, characterized in that: The preset algorithm is specifically: The categories of human body parts include calves, thighs, shoulders, and heads; The water depth is calculated according to the following formula: Among them, Depth ct Depth is the actual water depth when the feature image contains the calf and thigh. cs is the actual water depth when the feature image contains the calf and shoulder but not the thigh, ch Depth is the actual water depth when the feature image includes thighs and head but not calves and shoulders. ts Depth is the actual water depth when the feature image includes thighs and shoulders but not calves. th Depth is the actual water depth when the feature image includes thighs and head but not calves and shoulders. sh is the actual water depth when the feature image includes shoulders and head but not calves and thighs, h ac is the actual length of the calf, h at is the actual length of the thigh, h as is the actual length of the shoulder, h ah is the actual length of the head, λ c is the correction coefficient of the thigh, λ s is the correction coefficient for the shoulder, λ h is the correction coefficient of the head, h c is the pixel height of the bounding box corresponding to the calf, h t is the pixel height of the bounding box corresponding to the thigh, h s is the pixel height of the bounding box corresponding to the shoulder, h h is the pixel height of the bounding box corresponding to the head.
3. The water depth detection method based on the target detection model according to claim 2, characterized in that: The training process of the human body part detection model includes: Obtaining a training set; wherein the training set is a plurality of images containing human bodies and accumulated water; According to the training set, a basic detection model is constructed based on the YOLOv5 algorithm, wherein the basic detection model includes a focus structure, a convolution block, a cross-stage part, and a residual block; wherein the focus structure is used to reduce the size of the image; and the convolution block includes a convolution layer, a batch normalization layer, and a leaky ReLU layer; The basic detection model is trained using the training set. The loss function corresponding to each training is calculated based on the output of the basic detection model, and the model parameters of the basic detection model are updated through the back propagation algorithm until the basic detection model meets the preset convergence conditions, thereby obtaining the trained human body part detection model.
4. The water depth detection method based on the target detection model according to claim 3, characterized in that: The loss function of the basic detection model includes bounding box loss, confidence loss and class loss; the bounding box loss adopts the CloU-loss function.
5. The water depth detection method based on the target detection model according to claim 3, characterized in that: The specific steps of obtaining the training set are: On social media, the YOLOv3 algorithm was used to search for images containing human bodies and water accumulation. Delete images with the same MD5 value from the searched images to obtain the first data set; Label the calves, thighs, shoulders, and heads in all images in the first dataset; The labeled images are enhanced and expanded to obtain the training set; wherein the enhancement processing includes horizontal flipping processing, grayscale processing, and brightness processing.
6. A water depth detection system based on a target detection model, characterized in that: It includes image acquisition module, feature extraction module and water depth detection module; among them, The image acquisition module is used to acquire an image to be detected; wherein the image to be detected is an image containing a human body and accumulated water; The feature extraction module is used to input the image to be detected into a pre-trained human body part detection model to obtain a feature image; the feature image includes detected bounding box information and detected human body part information; the detected human body part information includes the category of the human body part and the actual length corresponding to each human body part; the bounding box information includes the pixel height of the bounding box corresponding to each human body part; The water depth detection module is configured to calculate the depth of the accumulated water in the image to be detected based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box; The water depth detection module calculates the depth of the water in the image to be detected based on the actual length of the human body part in the detected human body part information and the pixel height of the bounding box, specifically: When the feature image contains only one person, the water depth detection module calculates the depth of the water in the image to be detected based on the actual lengths of the first and second categories and the pixel height of the bounding box, combined with a preset algorithm; wherein the first category is the lowest human body part detected, and the second category is the adjacent category detected to the first category; When the feature image contains multiple people, the water depth detection module matches each first category with the corresponding second category based on the difference in the minimum value of the bounding box on the x-axis; based on the matched first and second categories, combined with the preset algorithm, the water depth data corresponding to each person is calculated respectively, and the maximum water depth data is used as the accumulated water depth.
7. The water depth detection system based on the target detection model according to claim 6, characterized in that: The preset algorithm is specifically: The categories of human body parts include calves, thighs, shoulders, and heads; The water depth is calculated according to the following formula: Among them, Depth ct Depth is the actual water depth when the feature image contains the calf and thigh. cs is the actual water depth when the feature image contains the calf and shoulder but not the thigh, ch Depth is the actual water depth when the feature image includes thighs and head but not calves and shoulders. ts Depth is the actual water depth when the feature image includes thighs and shoulders but not calves. th Depth is the actual water depth when the feature image includes thighs and head but not calves and shoulders. sh is the actual water depth when the feature image includes shoulders and head but not calves and thighs, h ac is the actual length of the calf, h at is the actual length of the thigh, h as is the actual length of the shoulder, h ah is the actual length of the head, λ c is the correction coefficient of the thigh, λ s is the correction coefficient for the shoulder, λ h is the correction coefficient of the head, h c is the pixel height of the bounding box corresponding to the calf, h t is the pixel height of the bounding box corresponding to the thigh, h s is the pixel height of the bounding box corresponding to the shoulder, h h is the pixel height of the bounding box corresponding to the head.
8. The water depth detection system based on the target detection model according to claim 7, characterized in that: The training process of the human body part detection model includes: Obtaining a training set; wherein the training set is a plurality of images containing human bodies and accumulated water; According to the training set, a basic detection model is constructed based on the YOLOv5 algorithm, wherein the basic detection model includes a focus structure, a convolution block, a cross-stage part, and a residual block; wherein the focus structure is used to reduce the size of the image; and the convolution block includes a convolution layer, a batch normalization layer, and a leaky ReLU layer; The basic detection model is trained using the training set. The loss function corresponding to each training is calculated based on the output of the basic detection model, and the model parameters of the basic detection model are updated through the back propagation algorithm until the basic detection model meets the preset convergence conditions, thereby obtaining the trained human body part detection model.
Citation Information
Patent Citations
Real-time fall detection method based on depth image sequence
CN115346272A
Deep learning system for cuboid detection
US20180137642A1