A drowning prevention risk identification method and system based on machine vision

By applying machine vision technology in drowning risk identification, including image noise reduction, enhancement, background difference method and particle filter, efficient detection and drowning recognition of swimmers are achieved, and the problems of low accuracy and slow recognition in the prior art are solved, and safety and efficiency are improved.

CN119418397BActive Publication Date: 2025-04-15ZHUHAI WANGZHIWANG SOFTWARE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411453229.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-04-15
Estimated Expiration
2044-10-17

AI Technical Summary

Technical Problem

The existing drowning risk identification methods have problems such as low recognition accuracy, slow identification speed, manpower and material resources, and are prone to safety accidents.

Method used

The anti-drowning risk identification method based on machine vision is adopted, and image noise reduction and adaptive multi-scale image enhancement are performed through the Mean Shift algorithm. Combined with background difference method and particle filter, the detection and tracking of swimmers are realized, and drowning identification is performed based on the movement speed, saturation and continuous disappearing frame number.

Benefits of technology

It improves the accuracy and speed of drowning detection, reduces manpower and material consumption, enhances the timely identification and alarm of drowning incidents, and effectively avoids the occurrence of safety accidents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119418397B_ABST
    Figure CN119418397B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of drowning identification, and discloses a method and system for drowning risk identification based on machine vision. First, the initial swimming pool monitoring image is obtained, and after noise reduction processing is performed using the Mean Shift algorithm, adaptive multi-scale image enhancement is performed to obtain a set of processed swimming pool monitoring images; secondly, a codebook background model is established using the background difference method, and the pixel points in the processed swimming pool monitoring image set are compared to see whether they match the codebook background model, and the foreground points are obtained to complete the detection of swimmers; then a tracking target model is established to obtain the tracking target, and the swimmer is tracked by calculating the distance of the tracking target; finally, the swimmer is identified for drowning in three aspects: the swimmer's movement speed, the image saturation component value, and the number of consecutive frames in which the swimmer disappears. The present invention processes the swimming pool monitoring image, detects and tracks the swimmer to achieve drowning risk identification, and the method is objective and accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of drowning identification, and in particular to a method and system for preventing drowning risks based on machine vision. Background Art

[0002] Chinese patent CN111339892B discloses a method for detecting drowning in a swimming pool based on an end-to-end 3D convolutional neural network. The method specifically includes: obtaining surveillance video from a camera in the swimming pool area, performing pixel-level binary labeling on the surveillance video to obtain a video data set; obtaining a video clip of a fixed length from the video data set, inputting the video clip of the fixed length into a 3D convolutional neural network, obtaining the spatiotemporal features of the video frequency band, and then sampling and cascading the spatiotemporal features of the video frequency band to obtain a feature cube of the video clip; obtaining a segmentation map of each frame in the input video clip based on the feature cube of the video clip, and locating the behavior target in the video; pooling the feature cube corresponding to the behavior target in the video to obtain a label, and using the label to determine whether drowning behavior occurs in the swimming pool area, and if abnormal behavior such as drowning occurs, an alarm is issued. This method does not process the surveillance video, has a slow recognition speed, and occupies a large storage space.

[0003] Traditional drowning risk identification methods require the use of surveillance videos and real-time monitoring by staff, which consumes manpower and material resources. There may be negligence in monitoring, leading to danger. At the same time, traditional drowning risk identification methods have low recognition accuracy and cannot meet work requirements. They also do not use high-tech technologies such as machine vision, resulting in slow recognition speed, untimely processing, and other problems, which easily lead to frequent safety accidents. Summary of the invention

[0004] In response to the problems in the related art, the present invention provides a method and system for preventing drowning risks based on machine vision to overcome the above-mentioned technical problems existing in the existing related art.

[0005] In order to solve the above technical problems, the present invention is achieved through the following technical solutions:

[0006] The present invention is a method for identifying drowning risk based on machine vision, comprising the following steps:

[0007] S1. Obtain a swimming pool monitoring video to obtain an initial swimming pool monitoring image set, perform noise reduction processing on the initial swimming pool monitoring image set based on a Mean Shift algorithm, and then perform adaptive multi-scale image enhancement to obtain a processed swimming pool monitoring image set;

[0008] S2, converting the processed swimming pool monitoring images in the processed swimming pool monitoring image set into a processed swimming pool monitoring image matrix, establishing a codebook background model based on a background difference method, and detecting swimmers in the processed swimming pool monitoring image set by judging whether a pixel point in the processed swimming pool monitoring image matrix is ​​a foreground point, thereby obtaining a detected swimming pool monitoring image set;

[0009] S3, establishing a tracking target model to obtain the tracking target, generating a distance judgment matrix by calculating the distance of the tracking target, using the distance judgment matrix to judge the distance of the swimmer in the detected swimming pool monitoring image set, completing the swimmer tracking, and obtaining the processed initial swimming pool monitoring image set;

[0010] S4. According to the swimmer's movement speed, the image saturation component value and the number of consecutive disappearance frames of the swimmer, the swimmer in the processed initial swimming pool monitoring image set is identified as drowning, and an alarm is issued to complete the drowning prevention risk identification.

[0011] The invention obtains an initial swimming pool monitoring image, performs noise reduction processing on the initial swimming pool monitoring image based on the Mean Shift algorithm to obtain a noise-reduced swimming pool monitoring image, and then performs adaptive multi-scale image enhancement on the noise-reduced swimming pool monitoring image; by preprocessing the initial swimming pool monitoring image, the image blur phenomenon is effectively overcome, image segmentation and smoothing operations are achieved, and the influence of the swimming pool environment on the water source can be removed at the same time to reduce errors; secondly, by extracting the code word features of the swimming pool monitoring image, a codebook background model is established using the background difference method, and the image foreground points are matched by comparing the threshold to achieve detection of swimmers; by constructing a model, this method can overcome the complex background of the swimming pool environment and improve detection accuracy; then, particles are used to represent the probability distribution, a tracking target model is constructed to obtain the tracking target, and the distance of the tracking target on the trajectory is calculated to determine the motion trajectory of the tracking target in the swimming pool monitoring image to achieve tracking of the swimmer; this method uses random particles to estimate the moving target, and the tracking effect is good and the accuracy is high; finally, according to the movement speed of the swimmer, the image saturation component value and the number of consecutive disappearance frames of the swimmer, the drowning of the swimmer in the swimming pool monitoring image is identified, and an alarm is triggered if a suspected drowning incident occurs.

[0012] Preferably, the S1 comprises the following steps:

[0013] S11, obtaining a swimming pool monitoring video, intercepting a picture in the video as an initial swimming pool monitoring image, obtaining an initial swimming pool monitoring image set, selecting m×n sample points on the initial swimming pool monitoring image in the initial swimming pool monitoring image set, and quantizing the sample points to generate an initial swimming pool monitoring image matrix A as follows:

[0014]

[0015] Among them, a mn represents the mth horizontal and nth vertical pixel in the initial swimming pool monitoring image;

[0016] The Mean Shift algorithm is used to perform noise reduction processing on the initial swimming pool monitoring image in the initial swimming pool monitoring image set to obtain the noise-reduced swimming pool monitoring image set. The specific steps are as follows:

[0017] S111, selecting the first pixel point at the upper left end of the initial swimming pool monitoring image matrix as the starting pixel point, in a square area with a length of α, α being the spatial bandwidth, the square area in the initial swimming pool monitoring image matrix, setting the spatial component of the pixel points in the square area, combining the starting pixel point, the spatial component and the spatial bandwidth to calculate the weights of all the pixel points in the square area, and sequentially obtaining the weights of the pixel points in the initial swimming pool monitoring image matrix;

[0018] S112, select the cth pixel point in the initial swimming pool monitoring image matrix, denoted as a c , setting the value range bandwidth to β, the pixel value of the smoothed pixel in the initial swimming pool monitoring image matrix is The number of pixels in the initial swimming pool monitoring image is b, and the Mean Shift vector calculation formula is as follows:

[0019]

[0020] in, Represents the Mean Shift vector of the smoothed pixels in the initial pool monitoring image matrix, represents the kernel function, b′(c) represents the weight of the c-th pixel in the initial swimming pool monitoring image matrix;

[0021] S113, setting the error threshold to ω, the color vector of the smoothed pixel in the initial swimming pool monitoring image matrix is when When , the Mean Shift vector of the pixel point smoothed in the initial swimming pool monitoring image matrix is ​​assigned to the color vector of the pixel point smoothed in the initial swimming pool monitoring image matrix; otherwise, the iteration of the pixel point smoothed in the initial swimming pool monitoring image matrix is ​​terminated, and the Mean Shift vector of other pixel points in the initial swimming pool monitoring image matrix is ​​calculated to complete the denoising of the initial swimming pool monitoring image in the initial swimming pool monitoring image set, and the denoised swimming pool monitoring image is obtained to form the denoised swimming pool monitoring image set;

[0022] S12, performing adaptive multi-scale image enhancement on the denoised swimming pool monitoring images in the denoised swimming pool monitoring image set to obtain a processed swimming pool monitoring image set, the specific steps are as follows:

[0023] S121, extracting three-channel color components of the denoised swimming pool monitoring image, calculating an average value of the three-channel color components, and obtaining a three-channel color ratio coefficient according to the average value of the three-channel color components;

[0024] S122, setting a high-pass filter function, using the high-pass filter function to perform a multi-scale image enhancement operation on the three-channel color components, and performing weighted processing to obtain three-channel color enhancement components, and generating an enhanced swimming pool monitoring image;

[0025] S123, stretching the enhanced swimming pool monitoring image to obtain new three-channel color components, adjusting the new three-channel color components in combination with the three-channel color ratio coefficients to obtain final three-channel color components, fusing the final three-channel color components to generate a processed swimming pool monitoring image, and obtaining a processed swimming pool monitoring image set.

[0026] This invention uses the Mean Shift algorithm to perform noise reduction on the initial swimming pool monitoring image, which can effectively overcome the image blur phenomenon, realize image segmentation and smoothing operations, and then perform adaptive multi-scale image enhancement on the noise-reduced swimming pool monitoring image, which can remove the impact of the swimming pool environment on the water source and reduce errors.

[0027] Preferably, S2 comprises the following steps:

[0028] S21, generating a processed swimming pool monitoring image matrix A′ according to the processed swimming pool monitoring image in the processed swimming pool monitoring image set as follows:

[0029]

[0030] Among them, a′ m′n′ represents the m′th horizontal pixel and n′th vertical pixel in the processed swimming pool monitoring image;

[0031] Construct a new swimming pool monitoring image matrix and establish a codebook background model. The specific steps are as follows:

[0032] S211, reacquire e processed swimming pool monitoring images, generate a new swimming pool monitoring image matrix, use the RGB features of the pixels in the new swimming pool monitoring image matrix as codebook features, select pixels in the new swimming pool monitoring image matrix The first pixel is recorded as the first pixel, and the codebook feature set of the first pixel in the e processed swimming pool monitoring images is set to C = {d1, d2, d3, ..., de}, where d e The codebook feature of the first pixel in the e-th processed swimming pool monitoring image is represented. The dimension of the codebook feature in the codebook feature set is e1, the upper bound of the dimension of the codebook feature in the codebook feature set is b1(e1), the lower bound of the dimension of the codebook feature in the codebook feature set is b2(e1), the maximum value of the codebook feature in each dimension in the codebook feature set is bmax(e1), and the minimum value of the codebook feature in each dimension in the codebook feature set is bmin(e1). The codeword binary C1 is constructed as follows:

[0033] C1={b1(e1),b2(e1),bmax(e1),bmin(e1)};

[0034] S212, select any pixel point in the new swimming pool monitoring image matrix, record it as the second pixel point, calculate the codebook feature set of the second pixel point, when the codebook feature of the second pixel point in the codebook feature set of the second pixel point is greater than or equal to the lower limit of the dimension of the codebook feature in the codebook feature set, and the codebook feature of the second pixel point in the codebook feature set of the second pixel point is less than or equal to the upper limit of the dimension of the codebook feature in the codebook feature set, establish a new codeword binary group C2; otherwise, the codeword cannot be matched, and the codeword binary group of all the pixels in the new swimming pool monitoring image matrix is ​​obtained to generate an initial codebook background model C′={C1,C2,C3,...,C e′}, where C e′ represents the e′th codeword binary;

[0035] S213, setting the longest unmatched time interval of codewords of the codeword binary in the initial codebook background model to e2, setting the time interval threshold to ξ, and when the longest unmatched time interval of codewords of the codeword binary in the initial codebook background model is less than or equal to the time interval threshold, retaining the codeword binary corresponding to the longest unmatched time interval of codewords; otherwise, deleting the codeword binary corresponding to the longest unmatched time interval of codewords, and obtaining the codebook background model;

[0036] S22. Select any pixel point in the processed swimming pool monitoring image matrix, record it as a detection pixel point, set the pixel value of the detection pixel point to e2, the upper limit of the foreground judgment threshold to ψ1, and the lower limit of the foreground judgment threshold to ψ2. When the pixel value of the detection pixel point satisfies ψ2-bmin(e1)≤e2≤ψ1-bmax(e1), the detection pixel point satisfies the codebook background model. At this time, the detection pixel point is a background point, and the codebook background model is updated; otherwise, the detection pixel point is a foreground point point, and all foreground points in the processed swimming pool monitoring image matrix are extracted to form a foreground moving target, which is a swimmer. The foreground moving target is marked to obtain a detected swimming pool monitoring image to form a detected swimming pool monitoring image set.

[0037] The invention extracts codeword features from the swimming pool monitoring image, uses the background difference method to screen codeword binaries, establishes a codebook background model, and matches the foreground points of the image by comparing thresholds, thereby achieving detection of swimmers. This method can overcome the complex background influence of the swimming pool environment through modeling and improve detection accuracy.

[0038] Preferably, S3 comprises the following steps:

[0039] S31, according to the detected swimming pool monitoring image in the detected swimming pool monitoring image set, using a particle filter to establish a tracking target model, tracking the swimmer, and obtaining a tracking target, the specific steps are as follows:

[0040] S311, in the detected swimming pool monitoring image set, set the number of particles to g, obtain a particle sample set, calculate the weight of the particle samples in the particle sample set, select g1 particle samples according to the weight, calculate the cumulative array of g1 particle samples, and generate a particle sample cumulative array; use the binary method to resample the particle sample cumulative array, update the particle samples, and obtain a new particle sample set;

[0041] S312, calculating the color histogram of the new particle sample in the new particle sample set, using the particle filter to train the tracking target model to obtain the color histogram of the tracking target model, updating the weight of the new particle sample according to the similarity between the color histogram of the new particle sample and the color histogram of the tracking target model to obtain a new weight value, and using the new weight value to track the swimmer to obtain the tracking target;

[0042] S32, setting the number of tracked targets to m″, the number of trajectories of each tracked target to n″, and establishing a target association matrix A″ as follows:

[0043]

[0044] Among them, a′ m ″ ′n″ represents the n″th trajectory of the m″th tracking target;

[0045] A tracking target in the target association matrix is ​​selected and recorded as the first tracking target. The tracking target closest to the first tracking target on the trajectory is calculated. The distance between the first tracking target and the closest tracking target is recorded as the first tracking target distance. The distance threshold is set as ζ. When the first tracking target distance is less than the distance threshold, the first tracking target is set to 1; otherwise, the first tracking target is set to 0. Then other tracking targets are selected from the target association matrix to obtain a distance judgment matrix.

[0046] When the element in the distance judgment matrix is ​​1, the trajectories of the tracking targets are associated, the tracking target positions are matched successfully, the mean of the tracking target trajectories is used as the current position of the tracking target, the current position of the swimmer is obtained in the processed initial swimming pool monitoring image, and the swimmer's motion trajectory is obtained; when the element in the distance judgment matrix is ​​0, the tracking target position is not matched successfully, the number of disappearances of the tracking target is calculated, and the number threshold is set to σ. When the number of disappearances of the tracking target is greater than the number threshold, the tracking target disappears and the tracking target is not tracked; the tracking of the swimmer is completed, and a processed initial swimming pool monitoring image set is obtained.

[0047] The invention uses particles to construct a tracking target model to obtain the tracking target, then calculates the distance of the tracking target on the trajectory, determines the motion trajectory of the tracking target in the swimming pool monitoring image, tracks the swimmer, and obtains the swimmer's motion trajectory; this method uses random particles to estimate the moving target, and has good tracking effect and high accuracy.

[0048] Preferably, S4 comprises the following steps:

[0049] S41, for the swimmer in the processed initial swimming pool monitoring image set, judging whether the swimmer is suspected of being in a drowning state according to the swimmer's swimming speed, the image saturation component value and the number of consecutive image disappearance frames, the specific steps are as follows:

[0050] S411, locating the swimmer in the processed initial swimming pool monitoring image set, setting a circumscribed rectangular frame for the swimmer, and setting the center coordinates of the circumscribed rectangular frame of the swimmer in the hth processed initial swimming pool monitoring image as (x h ,y h ), the center coordinates of the bounding rectangle of the swimmer in the h′th processed initial swimming pool monitoring image are (x h′ ,y h′ ), then the movement speed v of the swimmer in the hth processed initial swimming pool monitoring image h The calculation formula is as follows:

[0051]

[0052] Set the motion speed threshold to The first time threshold is θ1. When the swimmer's movement time is greater than the movement time threshold and the swimmer's movement speed is less than the movement speed threshold, the swimmer is suspected to be in a drowning state; otherwise, the swimmer is in a normal state.

[0053] S412, calculating the saturation component value of the processed initial swimming pool monitoring image in the processed initial swimming pool monitoring image set and the minimum saturation component value of the swimmer, setting the second time threshold as θ2, when the minimum saturation component value of the swimmer is less than the saturation component value of the processed initial swimming pool monitoring image in the processed initial swimming pool monitoring image set, and the duration is greater than the second time threshold, the swimmer is suspected to be in a drowning state; otherwise, the swimmer is in a normal state;

[0054] S413, counting the number of frames in which the swimmer disappears continuously in the processed initial swimming pool monitoring image set, obtaining the number of frames in which the swimmer disappears continuously, setting a frame number threshold as τ, and when the number of frames in which the swimmer disappears continuously is greater than the frame number threshold, the swimmer is suspected to be in a drowning state; otherwise, the swimmer is in a normal state;

[0055] S42: When the swimmer's movement speed, image saturation component value, and the number of consecutive disappearance frames of the swimmer are in a suspected drowning state, an alarm is issued in time to complete drowning prevention risk identification.

[0056] The invention identifies drowning swimmers in swimming pool monitoring images from different aspects based on the swimmer's movement speed, image saturation component value and the number of frames in which the swimmer disappears continuously. It has a wide recognition range and can effectively avoid drowning safety accidents.

[0057] The present invention also discloses a system for a method for identifying drowning risks based on machine vision, which specifically includes: a swimming pool monitoring image noise reduction and enhancement module, a swimming pool monitoring image swimmer detection module, a swimming pool monitoring image swimmer tracking module and a drowning risk identification module;

[0058] The swimming pool monitoring image denoising and enhancement module is used to perform adaptive multi-scale image enhancement after denoising the swimming pool monitoring image;

[0059] The swimming pool monitoring image swimmer detection module is used to detect swimmers by determining whether a pixel point of the swimming pool monitoring image is a foreground point;

[0060] The swimming pool monitoring image swimmer tracking module is used to determine the distance of the swimmer in the swimming pool monitoring image to obtain the swimmer's movement trajectory;

[0061] The anti-drowning risk identification module is used to perform drowning identification based on the swimmer's movement speed, the image saturation component value and the number of consecutive disappearance frames of the swimmer.

[0062] The present invention has the following beneficial effects:

[0063] 1. The invention uses the Mean Shift algorithm to perform noise reduction on the initial swimming pool monitoring image, which can effectively overcome the image blurring phenomenon and realize image segmentation and smoothing operations.

[0064] 2. The invention can remove the impact of the swimming pool environment on the water source and reduce errors by performing adaptive multi-scale image enhancement on the noise-reduced swimming pool monitoring image.

[0065] 3. The present invention establishes a codebook background model by using a background difference method and matches the foreground points of the image by comparing thresholds, thereby realizing detection of swimmers. This can overcome the complex background influence of the swimming pool environment and improve detection accuracy.

[0066] 4. The invention uses particles to construct a tracking target model and determines the motion trajectory of the tracking target in the swimming pool monitoring image to achieve tracking of swimmers. This method uses random particles to estimate the moving target, and has good tracking effect and high accuracy.

[0067] 5. The invention identifies the drowning of swimmers in the swimming pool monitoring image from different aspects according to the swimmer's movement speed, image saturation component value and the number of consecutive frames in which the swimmer disappears. The identification range is wide and drowning accidents can be effectively avoided.

[0068] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] In order to more clearly illustrate the technical solutions of the embodiments of the invention, the drawings required for describing the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the invention. For ordinary technicians in this field, they can also obtain drawings based on these drawings without paying creative work.

[0070] Figure 1 A schematic diagram of the process of drowning prevention risk identification by a machine vision-based drowning prevention risk identification system provided by the present invention. DETAILED DESCRIPTION

[0071] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0072] In the description of the present invention, it is necessary to understand that the terms "opening", "upper", "lower", "top", "middle", "inside" and the like indicating orientation or positional relationship are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the components or elements referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore cannot be understood as limiting the invention.

[0073] Example 1

[0074] The present invention is a method for identifying drowning risk based on machine vision, comprising the following steps:

[0075] S1. Obtain a swimming pool monitoring video to obtain an initial swimming pool monitoring image set, perform noise reduction processing on the initial swimming pool monitoring image set based on a Mean Shift algorithm, and then perform adaptive multi-scale image enhancement to obtain a processed swimming pool monitoring image set;

[0076] The S1 comprises the following steps:

[0077] S11, obtaining a swimming pool monitoring video, intercepting a picture in the video as an initial swimming pool monitoring image, obtaining an initial swimming pool monitoring image set, selecting m×n sample points on the initial swimming pool monitoring image in the initial swimming pool monitoring image set, and quantizing the sample points to generate an initial swimming pool monitoring image matrix A as follows:

[0078]

[0079] Among them, a mn represents the mth horizontal and nth vertical pixel in the initial swimming pool monitoring image;

[0080] The Mean Shift algorithm is used to perform noise reduction processing on the initial swimming pool monitoring image in the initial swimming pool monitoring image set to obtain the swimming pool monitoring image set after noise reduction. The specific steps are as follows:

[0081] S111, selecting the first pixel point at the upper left end of the initial swimming pool monitoring image matrix as the starting pixel point, in a square area with a length of α, α being the spatial bandwidth, the square area in the initial swimming pool monitoring image matrix, setting the spatial component of the pixel points in the square area, combining the starting pixel point, the spatial component and the spatial bandwidth to calculate the weights of all the pixel points in the square area, and sequentially obtaining the weights of the pixel points in the initial swimming pool monitoring image matrix;

[0082] S112, select the cth pixel point in the initial swimming pool monitoring image matrix, denoted as a c , setting the value range bandwidth to β, the pixel value of the smoothed pixel in the initial swimming pool monitoring image matrix is The number of pixels in the initial swimming pool monitoring image is b, and the Mean Shift vector calculation formula is as follows:

[0083]

[0084] in, Represents the Mean Shift vector of the smoothed pixels in the initial pool monitoring image matrix, represents the kernel function, b′(c) represents the weight of the c-th pixel in the initial swimming pool monitoring image matrix;

[0085] S113, setting the error threshold to ω, the color vector of the smoothed pixel in the initial swimming pool monitoring image matrix is when When , the Mean Shift vector of the pixel point smoothed in the initial swimming pool monitoring image matrix is ​​assigned to the color vector of the pixel point smoothed in the initial swimming pool monitoring image matrix; otherwise, the iteration of the pixel point smoothed in the initial swimming pool monitoring image matrix is ​​terminated, and the Mean Shift vector of other pixel points in the initial swimming pool monitoring image matrix is ​​calculated to complete the denoising of the initial swimming pool monitoring image in the initial swimming pool monitoring image set, and the denoised swimming pool monitoring image is obtained to form the denoised swimming pool monitoring image set;

[0086] S12, performing adaptive multi-scale image enhancement on the denoised swimming pool monitoring images in the denoised swimming pool monitoring image set to obtain a processed swimming pool monitoring image set, the specific steps are as follows:

[0087] S121, extracting three-channel color components of the denoised swimming pool monitoring image, calculating an average value of the three-channel color components, and obtaining a three-channel color ratio coefficient according to the average value of the three-channel color components;

[0088] S122, setting a high-pass filter function, using the high-pass filter function to perform a multi-scale image enhancement operation on the three-channel color components, and performing weighted processing to obtain three-channel color enhancement components, and generating an enhanced swimming pool monitoring image;

[0089] S123, stretching the enhanced swimming pool monitoring image to obtain new three-channel color components, adjusting the new three-channel color components in combination with the three-channel color ratio coefficients to obtain final three-channel color components, fusing the final three-channel color components to generate a processed swimming pool monitoring image, and obtaining a processed swimming pool monitoring image set;

[0090] S2, converting the processed swimming pool monitoring images in the processed swimming pool monitoring image set into a processed swimming pool monitoring image matrix, establishing a codebook background model based on a background difference method, and detecting swimmers in the processed swimming pool monitoring image set by judging whether a pixel point in the processed swimming pool monitoring image matrix is ​​a foreground point, thereby obtaining a detected swimming pool monitoring image set;

[0091] The S2 comprises the following steps:

[0092] S21, generating a processed swimming pool monitoring image matrix A′ according to the processed swimming pool monitoring image in the processed swimming pool monitoring image set as follows:

[0093]

[0094] Among them, a′ m′n′ represents the m′th horizontal pixel and n′th vertical pixel in the processed swimming pool monitoring image;

[0095] Construct a new swimming pool monitoring image matrix and establish a codebook background model. The specific steps are as follows:

[0096] S211, reacquire e processed swimming pool monitoring images, generate a new swimming pool monitoring image matrix, use the RGB features of the pixels in the new swimming pool monitoring image matrix as codebook features, select pixels in the new swimming pool monitoring image matrix The first pixel is recorded as the first pixel, and the codebook feature set of the first pixel in the e processed swimming pool monitoring images is set to C = {d1, d2, d3, ..., d e}, where d e The codebook feature of the first pixel in the e-th processed swimming pool monitoring image is represented. The dimension of the codebook feature in the codebook feature set is e1, the upper bound of the dimension of the codebook feature in the codebook feature set is b1(e1), the lower bound of the dimension of the codebook feature in the codebook feature set is b2(e1), the maximum value of the codebook feature in each dimension in the codebook feature set is bmax(e1), and the minimum value of the codebook feature in each dimension in the codebook feature set is bmin(e1). The codeword binary C1 is constructed as follows:

[0097] C1={b1(e1),b2(e1),bmax(e1),bmin(e1)};

[0098] S212, select any pixel point in the new swimming pool monitoring image matrix, record it as the second pixel point, calculate the codebook feature set of the second pixel point, when the codebook feature of the second pixel point in the codebook feature set of the second pixel point is greater than or equal to the lower limit of the dimension of the codebook feature in the codebook feature set, and the codebook feature of the second pixel point in the codebook feature set of the second pixel point is less than or equal to the upper limit of the dimension of the codebook feature in the codebook feature set, establish a new codeword binary group C2; otherwise, the codeword cannot be matched, and the codeword binary group of all the pixels in the new swimming pool monitoring image matrix is ​​obtained to generate an initial codebook background model C′={C1,C2,C3,...,C e′}, where C e′ represents the e′th codeword binary;

[0099] S213, setting the longest unmatched time interval of codewords of the codeword binary in the initial codebook background model to e2, setting the time interval threshold to ξ, and when the longest unmatched time interval of codewords of the codeword binary in the initial codebook background model is less than or equal to the time interval threshold, retaining the codeword binary corresponding to the longest unmatched time interval of codewords; otherwise, deleting the codeword binary corresponding to the longest unmatched time interval of codewords, and obtaining the codebook background model;

[0100] S22, select any pixel point in the processed swimming pool monitoring image matrix, record it as a detection pixel point, set the pixel value of the detection pixel point to e2, the upper limit of the foreground judgment threshold to ψ1, and the lower limit of the foreground judgment threshold to ψ2. When the pixel value of the detection pixel point satisfies ψ2-bmin(e1)≤e2≤ψ1-bmax(e1), the detection pixel point satisfies the codebook background model. At this time, the detection pixel point is a background point, and the codebook background model is updated; otherwise, the detection pixel point is a foreground point point, and all foreground points in the processed swimming pool monitoring image matrix are extracted to form a foreground moving target, which is a swimmer. The foreground moving target is marked to obtain a detected swimming pool monitoring image to form a detected swimming pool monitoring image set;

[0101] S3, establishing a tracking target model to obtain the tracking target, generating a distance judgment matrix by calculating the distance of the tracking target, using the distance judgment matrix to judge the distance of the swimmer in the detected swimming pool monitoring image set, completing the swimmer tracking, and obtaining the processed initial swimming pool monitoring image set;

[0102] The S3 comprises the following steps:

[0103] S31, according to the detected swimming pool monitoring image in the detected swimming pool monitoring image set, using a particle filter to establish a tracking target model, tracking the swimmer, and obtaining a tracking target, the specific steps are as follows:

[0104] S311, in the detected swimming pool monitoring image set, set the number of particles to g, obtain a particle sample set, calculate the weight of the particle samples in the particle sample set, select g1 particle samples according to the weight, calculate the cumulative array of g1 particle samples, and generate a particle sample cumulative array; use the binary method to resample the particle sample cumulative array, update the particle samples, and obtain a new particle sample set;

[0105] S312, calculating the color histogram of the new particle sample in the new particle sample set, using the particle filter to train the tracking target model to obtain the color histogram of the tracking target model, updating the weight of the new particle sample according to the similarity between the color histogram of the new particle sample and the color histogram of the tracking target model to obtain a new weight value, and using the new weight value to track the swimmer to obtain the tracking target;

[0106] S32, setting the number of tracked targets to m″, the number of trajectories of each tracked target to n″, and establishing a target association matrix A″ as follows:

[0107]

[0108] Among them, a′ m ″ ′n″ represents the n″th trajectory of the m″th tracking target;

[0109] A tracking target in the target association matrix is ​​selected and recorded as the first tracking target. The tracking target closest to the first tracking target on the trajectory is calculated. The distance between the first tracking target and the closest tracking target is recorded as the first tracking target distance. The distance threshold is set as ζ. When the first tracking target distance is less than the distance threshold, the first tracking target is set to 1; otherwise, the first tracking target is set to 0. Then other tracking targets are selected from the target association matrix to obtain a distance judgment matrix.

[0110] When the element in the distance judgment matrix is ​​1, the trajectories of the tracking targets are associated, the tracking target positions are matched successfully, the mean of the tracking target trajectories is used as the current position of the tracking target, the current position of the swimmer is obtained in the processed initial swimming pool monitoring image, and the swimmer's motion trajectory is obtained; when the element in the distance judgment matrix is ​​0, the tracking target position is not matched successfully, the number of disappearances of the tracking target is calculated, and the number threshold is set to σ. When the number of disappearances of the tracking target is greater than the number threshold, the tracking target disappears and the tracking target is not tracked; the tracking of the swimmer is completed, and the processed initial swimming pool monitoring image set is obtained;

[0111] S4, according to the swimmer's movement speed, the image saturation component value and the number of consecutive disappearance frames of the swimmer, the swimmer in the processed initial swimming pool monitoring image set is identified as drowning, and an alarm is issued to complete the drowning prevention risk identification;

[0112] The S4 comprises the following steps:

[0113] S41, for the swimmer in the processed initial swimming pool monitoring image set, judging whether the swimmer is suspected of being in a drowning state according to the swimmer's swimming speed, the image saturation component value and the number of consecutive image disappearance frames, the specific steps are as follows:

[0114] S411, locating the swimmer in the processed initial swimming pool monitoring image set, setting a circumscribed rectangular frame for the swimmer, and setting the center coordinates of the circumscribed rectangular frame of the swimmer in the hth processed initial swimming pool monitoring image as (x h ,y h ), the center coordinates of the bounding rectangle of the swimmer in the h′th processed initial swimming pool monitoring image are (x h′ ,y h′ ), then the movement speed v of the swimmer in the hth processed initial swimming pool monitoring image h The calculation formula is as follows:

[0115]

[0116] Set the motion speed threshold to The first time threshold is θ1. When the swimmer's movement time is greater than the movement time threshold and the swimmer's movement speed is less than the movement speed threshold, the swimmer is suspected to be in a drowning state; otherwise, the swimmer is in a normal state.

[0117] S412, calculating the saturation component value of the processed initial swimming pool monitoring image in the processed initial swimming pool monitoring image set and the minimum saturation component value of the swimmer, setting the second time threshold as θ2, when the minimum saturation component value of the swimmer is less than the saturation component value of the processed initial swimming pool monitoring image in the processed initial swimming pool monitoring image set, and the duration is greater than the second time threshold, the swimmer is suspected to be in a drowning state; otherwise, the swimmer is in a normal state;

[0118] S413, counting the number of frames in which the swimmer disappears continuously in the processed initial swimming pool monitoring image set, obtaining the number of frames in which the swimmer disappears continuously, setting a frame number threshold as τ, and when the number of frames in which the swimmer disappears continuously is greater than the frame number threshold, the swimmer is suspected to be in a drowning state; otherwise, the swimmer is in a normal state;

[0119] S42: When the swimmer's movement speed, image saturation component value, and the number of consecutive disappearance frames of the swimmer are in a suspected drowning state, an alarm is issued in time to complete drowning prevention risk identification.

[0120] Example 2

[0121] The present invention also discloses a system for a method for identifying drowning risks based on machine vision, which specifically includes: a swimming pool monitoring image noise reduction and enhancement module, a swimming pool monitoring image swimmer detection module, a swimming pool monitoring image swimmer tracking module and a drowning risk identification module;

[0122] The swimming pool monitoring image denoising and enhancement module is used to perform adaptive multi-scale image enhancement after denoising the swimming pool monitoring image;

[0123] The swimming pool monitoring image swimmer detection module is used to detect swimmers by determining whether a pixel point of the swimming pool monitoring image is a foreground point;

[0124] The swimming pool monitoring image swimmer tracking module is used to determine the distance of the swimmer in the swimming pool monitoring image to obtain the swimmer's movement trajectory;

[0125] The anti-drowning risk identification module is used to perform drowning identification based on the swimmer's movement speed, the image saturation component value and the number of consecutive disappearance frames of the swimmer.

[0126] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0127] The preferred embodiments of the invention disclosed above are only used to help explain the invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the invention, so that those skilled in the art can understand and use the invention well.

Claims

1. A method for identifying drowning risk based on machine vision, characterized in that: The steps include: S1. Obtain a swimming pool monitoring video to obtain an initial swimming pool monitoring image set, perform noise reduction processing on the initial swimming pool monitoring image set based on a Mean Shift algorithm, and then perform adaptive multi-scale image enhancement to obtain a processed swimming pool monitoring image set; The S1 comprises the following steps: S11, obtaining a swimming pool monitoring video, intercepting a picture in the video as an initial swimming pool monitoring image, obtaining an initial swimming pool monitoring image set, and generating an initial swimming pool monitoring image matrix; using a Mean Shift algorithm to perform noise reduction processing on the initial swimming pool monitoring images in the initial swimming pool monitoring image set, and obtaining a noise-reduced swimming pool monitoring image set; S12, performing adaptive multi-scale image enhancement on the denoised swimming pool monitoring images in the denoised swimming pool monitoring image set to obtain a processed swimming pool monitoring image set; The method of using the Mean Shift algorithm to perform noise reduction processing on the initial swimming pool monitoring image in the initial swimming pool monitoring image set comprises the following steps: Calculate the weights of the pixels in the initial swimming pool monitoring image matrix, and obtain the Mean Shift vector according to the weights of the pixels in the initial swimming pool monitoring image matrix; obtain the color vectors of the smoothed pixels in the initial swimming pool monitoring image matrix, and use the Mean Shift vector to replace the color vectors of the smoothed pixels in the initial swimming pool monitoring image matrix by comparing the error threshold, so as to obtain the denoised swimming pool monitoring image set; The calculation of the weights of the pixels in the initial swimming pool monitoring image matrix comprises the following steps: The first pixel at the upper left end of the initial swimming pool monitoring image matrix is ​​selected as the starting pixel, and the length is The square area of That is, the spatial bandwidth, the square area is in the initial swimming pool monitoring image matrix, the spatial component of the pixel points in the square area is set, the weights of all the pixel points in the square area are calculated by combining the starting pixel point, the spatial component and the spatial bandwidth, and the weights of the pixel points in the initial swimming pool monitoring image matrix are obtained in turn; The S12 comprises the following steps: S121, extracting three-channel color components of the denoised swimming pool monitoring image, calculating an average value of the three-channel color components, and obtaining a three-channel color ratio coefficient according to the average value of the three-channel color components; S122, using a high-pass filter function to perform a multi-scale image enhancement operation on the three-channel color components, and after weighted processing, obtain three-channel color enhancement components to generate an enhanced swimming pool monitoring image; S123, stretching the enhanced swimming pool monitoring image to obtain new three-channel color components, adjusting the new three-channel color components in combination with the three-channel color ratio coefficients to obtain final three-channel color components, fusing the final three-channel color components to generate a processed swimming pool monitoring image, and obtaining a processed swimming pool monitoring image set; S2, converting the processed swimming pool monitoring images in the processed swimming pool monitoring image set into a processed swimming pool monitoring image matrix, establishing a codebook background model based on a background difference method, and detecting swimmers in the processed swimming pool monitoring image set by judging whether a pixel point in the processed swimming pool monitoring image matrix is ​​a foreground point, thereby obtaining a detected swimming pool monitoring image set; S3, establishing a tracking target model to obtain the tracking target, generating a distance judgment matrix by calculating the distance of the tracking target, using the distance judgment matrix to judge the distance of the swimmer in the detected swimming pool monitoring image set, completing the swimmer tracking, and obtaining the processed initial swimming pool monitoring image set; S4. According to the swimmer's movement speed, the image saturation component value and the number of consecutive disappearance frames of the swimmer, the swimmer in the processed initial swimming pool monitoring image set is identified as drowning, and an alarm is issued to complete the drowning prevention risk identification.

2. The method for preventing drowning risk based on machine vision according to claim 1, characterized in that: The S2 comprises the following steps: S21, generating a processed swimming pool monitoring image matrix according to the processed swimming pool monitoring images in the processed swimming pool monitoring image set, constructing a new swimming pool monitoring image matrix, and establishing a codebook background model; S22, selecting detection pixels in the processed swimming pool monitoring image matrix, matching the detection pixels with the codebook background model, obtaining a foreground moving target, completing the detection of the swimmer, and obtaining a set of swimming pool monitoring images after detection.

3. The method for preventing drowning risk based on machine vision according to claim 2, characterized in that: The step of establishing the codebook background model comprises the following steps: Re-acquisition e The processed swimming pool monitoring image is used to generate a new swimming pool monitoring image matrix, extract the codebook features of the pixel points in the new swimming pool monitoring image matrix, construct a codeword binary, and generate an initial codebook background model; the initial codebook background model is compared with a threshold, and the unmatched codeword binary is deleted to obtain a codebook background model.

4. The method for preventing drowning risk based on machine vision according to claim 3 is characterized in that: The S3 comprises the following steps: S31, using a particle filter to establish a tracking target model based on the detected swimming pool monitoring image in the detected swimming pool monitoring image set, and tracking the swimmer to obtain a tracking target; S32. Establish a target association matrix according to the tracking target, compare the distance of the tracking target in the target association matrix with the distance threshold, and generate a distance judgment matrix; when the element in the distance judgment matrix is ​​1, the position of the tracking target is successfully matched, and when the element in the distance judgment matrix is ​​0, the position of the tracking target is not successfully matched; the tracking target is a swimmer, and the tracking of the swimmer is completed to obtain a processed initial swimming pool monitoring image set.

5. The method for preventing drowning risk based on machine vision according to claim 4, characterized in that: The S4 comprises the following steps: S41, for a swimmer in the processed initial swimming pool monitoring image set, judging whether the swimmer is suspected of being in a drowning state according to the swimmer's swimming speed, the image saturation component value, and the number of consecutive image disappearance frames; S42. When a swimmer is suspected of drowning, call the police immediately to identify the risk of drowning.

6. A system for implementing the method for identifying drowning risk based on machine vision as claimed in any one of claims 1 to 5, characterized in that: Specifically include: Pool monitoring image noise reduction and enhancement module, pool monitoring image swimmer detection module, pool monitoring image swimmer tracking module and drowning prevention risk identification module; The swimming pool monitoring image denoising and enhancement module is used to perform adaptive multi-scale image enhancement after denoising the swimming pool monitoring image; The swimming pool monitoring image swimmer detection module is used to detect swimmers by determining whether a pixel point of the swimming pool monitoring image is a foreground point; The swimming pool monitoring image swimmer tracking module is used to determine the distance of the swimmer in the swimming pool monitoring image to obtain the swimmer's movement trajectory; The anti-drowning risk identification module is used to perform drowning identification based on the swimmer's movement speed, the image saturation component value and the number of consecutive disappearance frames of the swimmer.

Citation Information

Patent Citations

  • A method for detecting drowning in swimming pools based on end-to-end 3D convolutional neural networks

    CN111339892B

  • Video-based detection method for drowning event in swimming pool

    CN106022230A

  • Multi-target tracking method based on multiple feature combination and Mean Shift algorithm

    CN106204643A