Mask wearing compliance detection method, device and equipment and storage medium

Through video stream detection and tracking technology, combined with the YOLOv5-LITE model, the problem of mask wearing compliance for monitoring personnel in public places is solved, efficient mask wearing detection is achieved, the number of management personnel is reduced and detection accuracy is improved.

CN118692016APending Publication Date: 2024-09-24CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310283179.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-22
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

The need to monitor whether people are wearing masks in public places has led to restrictions on the number of managers and restricted monitoring areas.

Method used

Using the moving target detection and tracking technology in the video stream, combined with the improved YOLOv5-LITE model, it detects whether there is a target face that does not wear the mask correctly in the video frame image, and issues an alarm through the user terminal.

Benefits of technology

It reduces the workload of managers, increases the monitorable area, improves the accuracy and speed of target detection, and reduces background interference.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118692016A
    Figure CN118692016A
Patent Text Reader

Abstract

The invention provides a mask wearing compliance detection method and device, equipment and a storage medium. The method comprises the following steps: acquiring a current frame image in a video stream and carrying out moving target detection on the current frame image; tracking the detected moving target, and intercepting a target area image of the same moving target; determining whether a target face image which does not correctly wear the mask exists in the target area image or not by adopting the trained mask wearing detection model; the mask wearing detection model after the training is completed is an improved YOLOv5-LITE model; if it is determined that the target face image which does not correctly wear the mask exists in the target area image, the target area image is sent to a user terminal, so that the user terminal gives an alarm for the behavior that the user terminal does not correctly wear the mask. Whether a person wears the mask in a compliance manner is determined through target detection, so that the workload is reduced, and a monitorable area is increased; in addition, background interference in the image is reduced, and the accuracy of target detection is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information security, and in particular to a mask wearing compliance detection method, device, equipment and storage medium. Background Art

[0002] In various public places such as buildings and restaurants, it is necessary to determine whether employees, customers and other personnel are wearing masks in compliance with regulations, so as to issue reminders for those who fail to wear masks in compliance when entering public places.

[0003] At present, relevant managers usually observe whether people entering public places are wearing masks in compliance with regulations through surveillance videos or on-site. Since relevant managers are required to observe whether people are wearing masks in compliance with regulations, and relevant managers must be arranged in key areas such as entrances, the number of relevant managers is limited. Summary of the invention

[0004] The present application provides a mask wearing compliance detection method, device, equipment and storage medium to solve the problem that relevant management personnel are required to observe whether people are wearing masks in compliance, and relevant management personnel need to be arranged in key areas such as each entrance, resulting in the monitored area being limited by the number of relevant management personnel.

[0005] In a first aspect, the present application provides a mask wearing compliance detection method, comprising:

[0006] Obtain the current frame image in the video stream and perform moving target detection on the current frame image;

[0007] Track the detected moving target and capture the target area image of the same moving target;

[0008] A trained mask wearing detection model is used to determine whether there is a target face image that does not wear a mask correctly in the target area image; the trained mask wearing detection model is an improved YOLOv5-LITE model;

[0009] If it is determined that the target face image of the person who is not wearing the mask correctly exists in the target area image, the target area image is sent to the user terminal so that the user terminal warns the user of the behavior of not wearing the mask correctly.

[0010] Optionally, performing moving target detection on the current frame image includes:

[0011] The ViBe algorithm is used to establish a background model for the current frame image in the video stream; the ViBe algorithm is used to perform foreground detection on the current frame image with the established background model, and the foreground area is determined as a moving target.

[0012] Optionally, the step of tracking the detected moving target and capturing a target area image of the same moving target includes:

[0013] If it is determined that the moving target enters the pre-set area of ​​interest in the current frame image, the moving target is tracked using a feature-based tracking algorithm or a region-based tracking algorithm to obtain the tracking trajectory of the moving target; the moving targets on the same tracking trajectory are determined to be the same moving target, and the target area image of the same moving target is captured.

[0014] Optionally, intercepting the target area image of the same moving target includes:

[0015] The resolution of the corresponding area of ​​the same moving target in each frame image is determined, and the corresponding area of ​​the moving target with a larger resolution is expanded to determine the expanded corresponding area of ​​the moving target; the expanded corresponding area of ​​the moving target is intercepted by using an external rectangle to obtain the target area image of the same moving target.

[0016] Optionally, the method of using the trained mask wearing detection model to determine whether there is a target face image of a person who is not wearing a mask correctly in the target area image includes:

[0017] The trained mask wearing detection model is used to detect the face in the target area image to obtain the category of the face area in the target area image; the category is: not wearing the mask correctly or wearing the mask correctly; based on the category of the face area in the target area image, it is determined whether there is a target face image in the current frame image that does not wear the mask correctly.

[0018] Optionally, training a mask wearing detection model includes:

[0019] Acquire a face dataset; the face dataset includes annotated images of side faces, annotated images of occluded faces, annotated images of small target face images, and annotated images of negative samples; the annotations in the face dataset are divided into three categories: compliant wearing of masks, non-compliant wearing of masks, and no wearing of masks; train a mask wearing detection model based on the face dataset; the mask wearing detection model includes: an input end, a backbone network, a neck network, and a prediction network; the input end of the mask wearing detection model includes an improved mosaic data enhancement operation module; the improved mosaic data enhancement operation module is used to splice every 16 images in the face dataset.

[0020] Optionally, the improved mosaic data enhancement operation module is used to stitch every 16 images in the face dataset, including:

[0021] Create an initial canvas and divide it into four sub-canvases; use the images in the four face datasets to stitch them in the corresponding sub-canvases according to the preset mosaic data enhancement operation mode to form a stitched image consisting of 16 images.

[0022] Optionally, the input end also includes a Gaussian blur algorithm: the Gaussian blur algorithm is used to perform Gaussian blur processing on the images in the face data set according to a preset ratio, so as to add blurred face images to the face data set.

[0023] Optionally, the backbone network in the mask wearing detection model includes: Megvii's lightweight convolutional neural network ShuffleNetv2; the ShuffleNetv2 includes an SE attention module; the SE attention module is used to perform channel feature enhancement processing on the input feature map.

[0024] Optionally, the neck network in the mask wearing detection model includes: a weighted bidirectional feature pyramid network BiFPN; the weighted bidirectional feature pyramid network is used to perform multi-scale feature fusion processing on input features.

[0025] In a second aspect, the present application provides a mask wearing compliance detection device, comprising:

[0026] A moving target detection module is used to obtain a current frame image in a video stream and perform moving target detection on the current frame image;

[0027] A moving target tracking module is used to track the detected moving target and capture the target area image of the same moving target;

[0028] A mask compliance recognition module is used to use a trained mask wearing detection model to determine whether there is a target face image that does not wear a mask correctly in the target area image; the trained mask wearing detection model is an improved YOLOv5-LITE model;

[0029] The sending module is used to send the target area image to the user terminal if it is determined that the target face image of the person who is not wearing the mask correctly exists in the target area image, so that the user terminal warns the user of the behavior of not wearing the mask correctly.

[0030] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory and a transceiver communicatively connected to the processor;

[0031] The memory stores computer-executable instructions; the transceiver is used to send and receive data;

[0032] The processor executes the computer-executable instructions stored in the memory to implement the mask wearing compliance detection method described in any of the above aspects.

[0033] In a fourth aspect, the present application provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by a processor, they are used to implement the mask wearing compliance detection method described in any of the above aspects.

[0034] The mask wearing compliance detection method, device, equipment and storage medium provided by the present application obtain the current frame image in the video stream and perform moving target detection on the current frame image; track the detected moving target and intercept the target area image of the same moving target; use the trained mask wearing detection model to determine whether there is a target face image that does not wear a mask correctly in the target area image; the trained mask wearing detection model is an improved YOLOv5-LITE model; if it is determined that there is a target face image that does not wear a mask correctly in the target area image, the target area image is sent to the user terminal so that the user terminal warns of the behavior of not wearing a mask correctly. Determining whether a person wears a mask in compliance through target detection reduces the workload of relevant management personnel and increases the monitored area; and, by pre-detecting and tracking moving targets, background interference in the image is reduced, the accuracy of target detection is improved, and the speed of determining whether there is a target face image that does not wear a mask correctly using the trained mask wearing detection model is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0036] Figure 1 A flow chart of a mask wearing compliance detection method provided in Example 1 of the present application;

[0037] Figure 2 A schematic diagram of an application scenario provided for an embodiment of the present application;

[0038] Figure 3 A schematic diagram of the moving target detection and tracking process provided in an embodiment of the present application;

[0039] Figure 4 A schematic diagram of a 3-layer bi-FPN network structure provided in an embodiment of the present application;

[0040] Figure 5 A schematic diagram of the structure of a mask wearing compliance detection device provided in Example 4 of the present application;

[0041] Figure 6This is a schematic diagram of the structure of an electronic device provided in Example 5 of the present application.

[0042] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0043] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0044] The terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. In the description of the following embodiments, "multiple" means more than two, unless otherwise clearly and specifically defined.

[0045] First, the prior art involved in the present invention is described and analyzed in detail.

[0046] At present, relevant management personnel are usually required to be arranged at key areas such as entrances to observe whether people entering public places wear masks in compliance, resulting in the monitored area being limited by the number of relevant management personnel.

[0047] The inventor found in the study that it is possible to determine whether a person is wearing a mask in compliance with the regulations by target detection, which can reduce the workload of relevant managers and increase the monitored area. And the inventor found that since the key areas for detecting whether a person is wearing a mask in compliance with the regulations are usually the entrances and exits of public places, the person to be detected is usually in a mobile state, so the image of the area where the moving target is located can be intercepted first, and the target face image of the moving area image can be identified to reduce background interference and improve the accuracy of target detection. Therefore, the present application provides a mask wearing compliance detection method, after obtaining the current frame image in the video stream, the current frame image is subjected to moving target detection; the detected moving target is tracked, and the target area image of the same moving target is intercepted; the trained mask wearing detection model is used to determine whether there is a target face image of the target area image that is not wearing a mask correctly; the trained mask wearing detection model is an improved YOLOv5-LITE model; if it is determined that there is a target face image of the target area image that is not wearing a mask correctly, the target area image is sent to the user terminal so that the user terminal is alerted to the behavior of not wearing a mask correctly.

[0048] In the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of information such as financial data or user data involved shall comply with the provisions of relevant laws and regulations and shall not violate public order and good morals.

[0049] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0050] Embodiment 1

[0051] Figure 1 The flowchart of the mask wearing compliance detection method provided in the first embodiment of the present application, the embodiment of the present application is aimed at the problem that relevant managers need to observe whether personnel wear masks in compliance, and relevant managers need to be arranged in key areas such as each entrance, resulting in the problem that the number of monitorable areas is limited by the number of relevant managers, and a mask wearing compliance detection method is provided. The method in this embodiment is applied to a mask wearing compliance detection device, and the mask wearing compliance detection device can be located in an electronic device. Among them, the electronic device can be a digital computer representing various forms. Such as a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers.

[0052] like Figure 1 As shown, the specific steps of this method are as follows:

[0053] Step S101: Acquire a current frame image in a video stream and perform moving target detection on the current frame image.

[0054] In the embodiment of the present application, the video stream may be collected by a camera installed in the desired monitoring area.

[0055] Figure 2 A schematic diagram of an application scenario provided in an embodiment of the present application, such as Figure 2 As shown, it includes a camera 1, an electronic device 2, and a user terminal 3; the camera 1 is communicatively connected to the electronic device 2, the electronic device 2 can obtain the video stream captured by the camera 1, and execute the mask wearing compliance detection method provided in the present application to determine whether there is a target face image in the target area image of the video stream that does not wear a mask correctly; if it is determined that there is a target face image that does not wear a mask correctly, the target area image is sent to the user terminal 3; the user terminal 3 can display the target face image that does not wear a mask correctly, and can display warning information that there is an incorrect mask wearing behavior.

[0056] Specifically, after acquiring the video stream, a key frame can be captured at regular intervals, and moving target detection can be performed on the current frame image; if it is determined that there is a moving target area in the current frame image, step S102 is executed to track the detected moving target; if it is determined that there is no moving target area in the current frame image, the next frame image is acquired and moving target detection is performed on the next frame image.

[0057] The embodiments of the present application do not limit the method of performing moving target detection. For example, a single Gaussian model or a mixed Gaussian model may be used for moving target detection, or a vibe algorithm or the like may be used for moving target detection.

[0058] Step S102: Track the detected moving target and capture a target area image of the same moving target.

[0059] The target area image is an image obtained by selecting a frame of image in the video stream for the same moving target and intercepting the area where the moving target is located. The target area image includes the moving target, and the same moving target corresponds to one target area image.

[0060] Specifically, after detecting the moving target in the current frame image, the detected moving target is tracked to determine the same moving target in each key frame image, and a target area image is captured for the same moving target.

[0061] The embodiment of the present application does not limit the tracking algorithm used, and traditional algorithms such as Kalman filter, particle filter, kernel correlation filter algorithm KCF and other algorithms are a series of algorithms. Among them, the correlation filter represented by KCF is the main algorithm framework used in the current industrial target tracking field.

[0062] Step S103: Use the trained mask wearing detection model to determine whether there is a target face image that does not wear a mask correctly in the target area image.

[0063] The trained mask wearing detection model is the improved YOLOv5-LITE model. The improved YOLOv5-LITE model is a lightweight target detection model that can detect target face images that are not wearing masks correctly in the target area image.

[0064] Step S104: If it is determined that there is a target face image in the target area image that does not wear a mask correctly, the target area image is sent to the user terminal so that the user terminal warns the user of the behavior of not wearing a mask correctly.

[0065] In an embodiment of the present application, if it is determined that there is no target face image of the person not wearing a mask correctly in the target area image, then it is determined that there is no behavior of not wearing a mask correctly, and there is no need to send the target area image to the user terminal; if it is determined that there is a target face image of the person not wearing a mask correctly in the target area image, then it is determined that there is a behavior of not wearing a mask correctly, and the image including the target area is sent to the user terminal so that the user terminal will warn of the behavior of not wearing a mask correctly.

[0066] Optionally, target face images without correctly wearing masks can also be stored.

[0067] The mask wearing compliance detection method provided by the embodiment of the present application obtains the current frame image in the video stream and performs moving target detection on the current frame image; tracks the detected moving target, and intercepts the target area image of the same moving target; uses the trained mask wearing detection model to determine whether there is a target face image that does not wear a mask correctly in the target area image; the trained mask wearing detection model is an improved YOLOv5-LITE model; if it is determined that there is a target face image that does not wear a mask correctly in the target area image, the target area image is sent to the user terminal so that the user terminal warns the behavior of not wearing a mask correctly. Determining whether a person wears a mask in compliance through target detection reduces the workload of relevant managers and increases the monitored area; and, by pre-detecting and tracking moving targets, background interference in the image is reduced, the accuracy of target detection is improved, and the speed of determining whether there is a target face image that does not wear a mask correctly using the trained mask wearing detection model is improved.

[0068] Embodiment 2

[0069] The following is a description of the mask wearing compliance detection method provided in the above embodiment with reference to a specific example, which specifically includes the following steps:

[0070] Step S201: Obtain the current frame image in the video stream.

[0071] Step S202: Use the ViBe algorithm to establish a background model for the current frame image in the video stream.

[0072] Step S203: Use the ViBe algorithm to perform foreground detection on the current frame image for which the background model has been established to determine the moving target.

[0073] In the embodiment of the present application, the ViBe algorithm is used for moving target detection. The ViBe algorithm is a background difference method. It should be understood that based on a single Gaussian model or a mixed Gaussian model, multiple frames (usually 30-50 frames) are required to model the background, while the ViBe algorithm only needs one frame to model the background, which improves the speed of background modeling.

[0074] Specifically, Figure 3 As shown, if it is determined that the current frame image is the first frame image in the video stream, a background model of the image is established; if it is determined that the current frame image is not the first frame image in the video stream, it is updated based on the established background model, and the updated background model is determined as the background model corresponding to the current frame image; after the background model of the current frame image is established, foreground detection is performed on the current frame image with the established background model to determine the moving target.

[0075] The method of establishing the background model of the first frame image based on the ViBe algorithm is as follows: assuming that the image size is M×N, a sample set needs to be established for each pixel point, and the size of each sample set is n, and the size of n can be 20. For a pixel point, combined with the spatial distribution characteristics of adjacent pixel points with similar pixel values, the pixel values ​​of its neighboring points are randomly selected as its model sample values ​​to complete the construction of the initial background sample set.

[0076] The method of establishing the background model of non-first frame images based on the ViBe algorithm is: 1) Memoryless update strategy: After determining that a certain pixel of the current frame is the background, if it is determined that the pixel sample set needs to be updated, a sample in the sample set is randomly selected for update; 2) Time sampling update strategy: Update according to a certain update rate. If we take the probability value rate as 16, there is a 1 / 16 probability of updating the background model; 3) Spatial neighborhood update strategy: The update not only occurs in the sample set of the current pixel, but also has a 1 / rate probability of updating the sample set of the neighboring pixels. If it is determined to be updated, a domain pixel is randomly selected to update its sample set.

[0077] The method of foreground detection based on the ViBe algorithm is as follows: each pixel of the input frame is compared with the pixels of the background sample set. If the distance is less than the threshold, the number of approximate sample points increases. If the number of approximate sample points is greater than the threshold, the pixel is considered to belong to the background pixel. Exemplarily, the parameters in the detection process include the threshold of the number of approximate sample points, which can be set to 2. It is considered that there must be at least 2 similar sample points. The distance threshold R can be set to 20. Finally, the foreground pixel is set to 255 and the background pixel is set to 0, and a segmented binary image is obtained, which contains the moving target.

[0078] It should be understood that in the ViBe algorithm, if there is a moving target to be detected in the first frame of the video stream, or when the moving target changes from a moving target to a background in the video, the background model cannot be updated in time, resulting in the background being misjudged as the foreground in the subsequent frames, which is a ghost area. Specifically, when the ViBe algorithm initializes the modeling of the background, the moving target may be in the background, and they will produce a ghost area after moving; in another case, when the moving target in the scene changes from moving to stationary and then starts to move, a ghost area will also be produced. Other situations similar to ghost areas are objects left in the background, or moving targets that have stopped moving. The ghost area can be removed by calculating the average gradient of the contour of the moving target. If the area is a ghost area, the target is no longer in this position, and the contour may be located in a relatively flat area, then the average gradient amplitude is very small, and contours with gradient amplitudes less than the gradient threshold G are excluded. The gradient threshold G can be taken as 30.

[0079] After using the gradient method to exclude some ghost areas, the area may still contain stationary pedestrians, and these are the targets we need to track and detect. Figure 3As shown, after determining the moving target, the moving target contour can also be post-processed to exclude moving targets that are too large or too small. For example, some moving targets whose areas are too large, such as moving targets that are larger than 80% of the entire image, or too small contours, such as noise, whose size is less than 7*7, can be excluded.

[0080] like Figure 3 As shown, after contour post-processing, the moving target can be tracked and a captured image frame of the image of the target area corresponding to the moving target can be determined.

[0081] Step S204: if it is determined that the moving target enters the preset region of interest in the current frame image, a feature-based tracking algorithm or a region-based tracking algorithm is used to track the moving target to obtain a tracking trajectory of the moving target.

[0082] The tracking algorithm used in the embodiments of the present application can be predetermined. For simple scenes, such as scenes with a small number of pedestrians, a tracking algorithm based on regional ROI can be used, that is, if the foreground distance between two adjacent frames is very close, it is considered to be the same target. This tracking method is extremely fast and does not require feature matching. Therefore, it can only be applied to scenes where most of the pedestrians in the region of interest are single pedestrians. For complex scenes, a region-based tracking algorithm can be used. The feature can be a color feature, a gradient feature (such as a gradient direction histogram) and other traditional features for tracking.

[0083] After the embodiment of the present application uses a feature-based tracking algorithm or a region-based tracking algorithm to track a moving target, a tracking track of the moving target is formed. Moving targets on the same tracking track can be determined as the same moving target, and a target area image of the same moving target can be captured.

[0084] Step S205: determine the moving targets on the same tracking trajectory as the same moving target, and capture the target area image of the same moving target.

[0085] Optionally, a method for capturing a target area image of the same moving target may be: determining the resolution of a corresponding area of ​​the same moving target in each frame image; dilating a moving target corresponding area with a larger resolution to determine an enlarged corresponding area of ​​the moving target; and using an external rectangle to capture the enlarged corresponding area of ​​the moving target to obtain a target area image of the same moving target.

[0086] In an embodiment of the present application, the maximum resolution foreground area corresponding to the same moving target can be expanded, wherein the size of the expanded area can be 15*15, which can expand the area of ​​some foreground areas and prevent missing a small part of the foreground area; after the maximum resolution foreground area is expanded, an circumscribed rectangle can be used to perform area capture to capture the target area image of the same moving target; after the target area image of the same moving target is captured, the face in the target area image can be detected.

[0087] Step S206: Use the trained mask wearing detection model to detect the face in the target area image to obtain the category of the face area in the target area image.

[0088] Step S207: Determine whether there is a target face image in the current frame image that does not wear a mask correctly based on the category of the face area in the target area image.

[0089] Step S208: If it is determined that there is a target face image in the target area image that does not wear a mask correctly, the target area image is sent to the user terminal so that the user terminal warns of the behavior of not wearing a mask correctly.

[0090] In the embodiment of the present application, the trained mask wearing detection model is used to detect the face in the target area image to obtain the target of interest in the target area image, that is, the face area, and determine their category and position. The category of the face area can be: not wearing a mask correctly or wearing a mask correctly.

[0091] Specifically, the trained mask wearing detection model can be used to determine the category and position of the target to be detected, i.e., the face, in the target area image. The category can usually be represented by a number, for example, the category of incorrectly wearing a mask is 1, and the category of correctly wearing a mask is 0; the position is usually represented by a bounding box (full name Bounding Box in English), which is a rectangular box that just contains the target to be detected, and can be determined by the x and y axis coordinates of the upper left corner of the rectangle and the x and y axis coordinates of the lower right corner. According to the output category of the target to be detected, i.e., the face, it can be determined whether there is a target face image that does not wear a mask correctly in the target area image.

[0092] In the embodiment of the present application, the trained mask wearing detection model is an improved YOLOv5-LITE model. YOLO is a representative algorithm based on region extraction. The YOLOv5-LITE model has low memory usage, fewer parameters, and faster detection speed. The improved YOLOv5-LITE model used in this application can also improve the accuracy of small target detection.

[0093] Embodiment 3

[0094] Based on the above embodiment 1, the specific steps of training the mask wearing detection model may include:

[0095] Step S301: Obtain a face dataset.

[0096] Among them, the dataset includes annotated images of side faces, annotated images of occluded faces, annotated images of small target faces, and annotated images of negative samples; the annotations in the face dataset are divided into three categories: wearing masks in compliance, wearing masks in non-compliance, and not wearing masks.

[0097] Specifically, you can first obtain face images from a public data set. For example, you can obtain face images without masks from the open source wider face data set, and obtain face images with masks from the open source mafa data set. If only public data sets are used for training, the average accuracy map of all categories can reach 0.92, but the faces contained in the face images in the public data sets are basically front faces, and the resolution of the faces is usually large. Therefore, for some complex scenes, including small targets, blurred and occluded faces, the effect is poor. Therefore, this application also adds side face annotated images, occluded face annotated images, small target face image annotated images, and negative sample annotated images to improve the model's average accuracy map of all categories. Among them, the average accuracy map of all categories is used to measure the performance of the target detection algorithm.

[0098] For example, the method of adding small targets, blurs, and occluded images of people wearing masks can be: obtain images of football stadium stands and subways, and annotate the faces in the acquired images. The scenes of these images are relatively complex, and the faces wearing masks contained therein have problems such as low resolution, blur, occlusion, and the face angles are relatively large. Adding these images to the face dataset can increase the accuracy of the mask wearing detection model trained based on the face dataset.

[0099] After adding small targets, blurred, and occluded annotated images of people wearing masks to the data set, we can add some negative sample data that are prone to false detection in order to reduce the probability of false detection.

[0100] Step S302: training a mask wearing detection model based on a face dataset.

[0101] Among them, the mask wearing detection model includes: an input end, a backbone network, a neck network and a prediction network; the input end of the mask wearing detection model includes an improved mosaic data enhancement operation module; the improved mosaic data enhancement operation module is used to splice every 16 images in the face data set.

[0102] Specifically, a face data set is input into the input end of a mask wearing detection model to perform data processing and data enhancement on the images in the data set; the data set output from the input end is input into a backbone network to perform feature extraction on the images in the data set; the output result of the backbone network is input into a neck network for feature fusion; the output result of the neck network is input into a prediction network to determine the prediction box position of the mask face and perform evaluation.

[0103] Optionally, the parameters in the mask wearing detection model include a size range parameter scale, which can control the image size after scaling the input image. For example, if the image tensor tensor is set to 640*640, and the size range parameter scale is usually 0.5, the size range of the length or width of the scaled image is 640*0.5 to 640*1.5. The size range parameter scale can be set to 0.9, and the size range of the length or width of the scaled image is determined to be 640*0.1 to 640*1.9, which increases the scaling range of the image and can provide more samples for images of different scales.

[0104] It should be understood that mosaic data enhancement operations are usually performed on 20 percent of the images in a data set. The embodiment of the present application performs an improved mosaic data enhancement operation on all images in the data set and uses 16 pictures for stitching, which can effectively increase the size of the mini-batch and improve the model convergence speed.

[0105] Optionally, an improved mosaic data enhancement operation module is used to stitch every 16 images in the face dataset, including: creating an initial canvas and dividing the initial canvas into four sub-canvases; using images in four face datasets to stitch them in corresponding sub-canvases according to a preset mosaic data enhancement operation method to form a stitched image consisting of 16 images.

[0106] It should be understood that the preset mosaic data enhancement operation can be a traditional mosaic data enhancement operation, which uses four pictures and splices the four pictures to obtain a new picture composed of four pictures. Specifically, it includes: randomly taking four pictures; performing data augmentation operations on the four pictures respectively; and combining pictures and frames.

[0107] The improved mosaic data enhancement operation module in the embodiment of the present application is used to stitch every 16 images in the face data set. After the initial canvas is equally divided into four sub-canvases, the traditional mosaic data enhancement operation is used in each of the four sub-canvases for stitching. Exemplarily, the size of the set tensor tensor is s, that is, the side length of the image is s, then an initial canvas with a side length of 4s can be created, and the initial canvas can be evenly divided into 4 sub-canvases, each of which has a side length of 2s. After each sub-canvas is processed according to the traditional mosaic data enhancement operation, the images of the 4 sub-canvases are finally combined together to obtain a stitched image consisting of 16 images.

[0108] When the spliced ​​image output from the input end is input into the backbone network, the spliced ​​image is scaled to the set tensor size. Therefore, the improved mosaic data enhancement operation is used to increase the number of small objects in the sample.

[0109] Optionally, the input end may also include a Gaussian blur algorithm: the Gaussian blur algorithm is used to perform Gaussian blur processing on the images in the face data set according to a preset ratio, so as to add blurred face images to the face data set.

[0110] Specifically, before performing the improved mosaic data enhancement operation on the data set, the Gaussian blur algorithm can be used to perform Gaussian blur processing on the images in the face data set at a preset ratio, so that blurred face images can be added to the face data set, which can improve the recognition accuracy in the case of blurred faces.

[0111] For example, the Gaussian blur algorithm can be added using the imageFilter of the pillow library, and the preset ratio can be determined as 0.2, wherein the mean value of the Gaussian blur is 0 and the variance is 1.

[0112] Optionally, the backbone network in the mask wearing detection model includes: Megvii's lightweight convolutional neural network ShuffleNetv2; ShuffleNetv2 includes an SE attention module; the SE attention module is used to perform channel feature enhancement processing on the input feature map.

[0113] Among them, the SE attention module is a channel attention module that can enhance the channel features of the input feature map, and the output of the SE attention module does not change the size of the input feature map. The SE attention module can explicitly model the interdependence between feature channels, obtain the importance of each channel through learning, and then weight the features on each channel according to this importance, so as to highlight important features and suppress unimportant features.

[0114] In the embodiment of the present application, the SE attention module is added after the ShuffleNetv2 lightweight convolutional neural network in the backbone network, which can enhance the channel features of the input feature map, enhance the important features in the feature map, and suppress the unimportant features, thereby improving the accuracy of feature extraction and further improving the recognition accuracy of the mask wearing detection model. However, it also introduces a speed increase of about 5%, which is finally considered acceptable after concurrent testing.

[0115] Optionally, the neck network in the mask wearing detection model includes: a weighted bidirectional feature pyramid network BiFPN; the weighted bidirectional feature pyramid network is used to perform multi-scale feature fusion processing on the input features.

[0116] It should be understood that in object detection models, fusing features of different scales is an important means to improve performance. Low-level features have higher resolution and contain more position and detail information, but because they have passed fewer convolutions, they are less semantic and have more noise. High-level features have stronger semantic information, but have low resolution and poor perception of details. Efficiently fusing low-level features with high-level features is the key to improving object detection models.

[0117] The traditional YOLOv5-LITE model has a PANet structure as its neck network. PANet is the first proposed bottom-up secondary fusion model structure. It simply adds a bottom-up fusion path based on the feature pyramid network FPN. The idea of ​​the weighted bidirectional feature pyramid network BiFPN is actually based on the path-enhanced PANet structure. After the top-down feature fusion, it is followed by another bottom-up fusion, which performs effective bidirectional cross-scale connection and weighted feature fusion.

[0118] BiFPN has three main improvements over PANet: 1. Cut some edges: BiFPN deletes nodes with only one in-degree, because the information of this node is the same as that of the previous node, which eliminates some redundant calculations. 2. Add some edges: BiFPN adds some jump connections, which are connected from the original feature nodes of the same layer to the output nodes. 3. The top-down and bottom-up fusion are constructed into a module so that it can be repeatedly stacked to enhance information fusion. PANet has only one top-down layer and one bottom-up layer.

[0119] BiFPN has also made improvements to the calculation of feature fusion. Traditional fusion calculations generally change the input feature maps to the same size and then add, multiply, or concatenate them. However, BiFPN takes into account that the contributions of different features may be different, so it weights the input features.

[0120] In an embodiment of the present application, replacing the PANet structure with a weighted feature pyramid BiFPN structure can improve the network's feature fusion capability for targets of different scales, thereby improving the detection accuracy of the mask wearing detection model.

[0121] In the embodiment of the present application, since the feature layer of the YOLOv5-LITE model is 3 layers, the neck network in the mask wearing detection model includes a 3-layer bi-FPN network, such as Figure 4 The dotted box shown is a 3-layer bi-FPN network. Specifically, deep separable convolution can be used for feature fusion, which can greatly reduce the number of parameters.

[0122] Optionally, a 4-layer bi-FPN network can also be used to further improve the effect of the mask wearing detection model on small target detection. Accordingly, it is necessary to add a YOLOv5-LITE feature layer, such as adding a 160*160 feature layer, but the detection speed will be reduced.

[0123] Optionally, the following four small target optimization methods can be used to increase the accuracy of small target detection by the mask wearing detection model:

[0124] 1. Directly add a larger feature layer and an anchor box.

[0125] 2. Add feature layers in the PANet network.

[0126] 3. Adding the attention CBAM module: CBAM can be seamlessly integrated into any CNN architecture, the overhead is not large, and it can be trained end-to-end with the basic CNN network. Suppose we have an intermediate feature F(H×W×C) as the output of the convolutional layer. Depending on the depth of the layer, each such feature layer captures useful information, such as simple edges, shapes, etc., to obtain more complex input semantic representations. We hope that the network will pay more attention to (i.e., focus on) the important parts of these feature maps.

[0127] 4. Divide the image into blocks and feed them to the neural network. This method can significantly improve the detection of small targets, but it requires that the images contain mostly small and medium-sized targets. If there are large targets, the targets will be fragmented and the speed increase will be very obvious.

[0128] Embodiment 4

[0129] Figure 5 This is a schematic diagram of the structure of the mask wearing compliance detection device provided in the fourth embodiment of the present application. The mask wearing compliance detection device provided in the embodiment of the present application can execute the processing flow provided in the embodiment of the mask wearing compliance detection method. Figure 5As shown, the mask wearing compliance detection device 40 includes: a moving target detection module 401, a moving target tracking module 402, a mask compliance identification module 403 and a sending module 404.

[0130] Specifically, the moving target detection module 401 is used to obtain a current frame image in a video stream and perform moving target detection on the current frame image;

[0131] A moving target tracking module 402 is used to track the detected moving target and capture a target area image of the same moving target;

[0132] The mask compliance recognition module 403 is used to use the trained mask wearing detection model to determine whether there is a target face image that does not wear a mask correctly in the target area image; the trained mask wearing detection model is an improved YOLOv5-LITE model;

[0133] The sending module 404 is used to send the target area image to the user terminal if it is determined that there is a target face image that does not wear a mask correctly in the target area image, so that the user terminal warns the user of the behavior of not wearing a mask correctly.

[0134] The device provided in the embodiment of the present application can be specifically used to execute the method embodiment provided in the above-mentioned embodiment 1, and the specific functions will not be repeated here.

[0135] Optionally, the moving target detection module 401 is specifically used to: use the ViBe algorithm to establish a background model for the current frame image in the video stream; use the ViBe algorithm to perform foreground detection on the current frame image with the established background model, and determine the foreground area as a moving target.

[0136] Optionally, the motion target tracking module 402 is specifically used for: if it is determined that the motion target enters a pre-set area of ​​interest in the current frame image, then a feature-based tracking algorithm or a region-based tracking algorithm is used to track the motion target to obtain the tracking trajectory of the motion target; the motion targets located on the same tracking trajectory are determined as the same motion target, and the target area image of the same motion target is captured.

[0137] Optionally, the moving target tracking module 402 includes a capture unit, which is used to: determine the resolution of the corresponding area of ​​the same moving target in each frame image, dilate the corresponding area of ​​the moving target with a larger resolution to determine the enlarged corresponding area of ​​the moving target; use an circumscribed rectangle to capture the enlarged corresponding area of ​​the moving target to obtain a target area image of the same moving target.

[0138] Optionally, the mask compliance identification module 403 is specifically used for:

[0139] The trained mask wearing detection model is used to detect the faces in the target area image to obtain the category of the face area in the target area image; the category is: not wearing the mask correctly or wearing the mask correctly; based on the category of the face area in the target area image, it is determined whether there is a target face image that does not wear the mask correctly in the current frame image.

[0140] Optionally, the mask wearing compliance detection device 40 also includes: a model training module; the model training module is used to: obtain a face data set; the face data set is used to annotate images for side faces, annotate images for occluded faces, annotate images for small target face images, and annotate images for negative samples; the annotations in the face data set are divided into 3 categories: compliant wearing of masks, non-compliant wearing of masks, and no wearing of masks; the mask wearing detection model is trained based on the face data set; the mask wearing detection model is used for: input end, backbone network, neck network, and prediction network; the input end of the mask wearing detection model is used for improved mosaic data enhancement operations; the improved mosaic data enhancement operation module is used to splice every 16 images in the face data set.

[0141] Optionally, the model training module includes a data enhancement unit; the data enhancement unit is used to: create an initial canvas and divide the initial canvas into four sub-canvases; respectively use images in four face data sets to splice in corresponding sub-canvases according to a preset mosaic data enhancement operation method to form a spliced ​​image consisting of 16 images.

[0142] Optionally, the input end of the mask wearing detection model also includes a Gaussian blur algorithm: the Gaussian blur algorithm is used to perform Gaussian blur processing on the images in the face data set at a preset ratio to add blurred face images to the face data set.

[0143] Optionally, the backbone network in the mask wearing detection model includes: Megvii's lightweight convolutional neural network ShuffleNetv2; ShuffleNetv2 is then used for the SE attention module; the SE attention module is used to perform channel feature enhancement processing on the input feature map.

[0144] Optionally, the neck network in the mask wearing detection model includes: a weighted bidirectional feature pyramid network BiFPN; the weighted bidirectional feature pyramid network is used to perform multi-scale feature fusion processing on the input features.

[0145] The device provided in the embodiment of the present application can be specifically used to execute the above method embodiment, and the specific functions will not be repeated here.

[0146] Embodiment 5

[0147] Figure 6 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present application, such as Figure 6 As shown, the present application also provides an electronic device 50, including: a processor 501, and a memory 502 and a transceiver 503 that are communicatively connected to the processor 501. The memory 502 stores computer-executable instructions; the transceiver 503 is used to send and receive data; the processor 501 executes the computer-executable instructions stored in the memory 502 to implement the method provided in any embodiment of the present application.

[0148] Specifically, the program may include a program code, and the program code includes a computer-executable instruction. The memory 502 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. Among them, the computer-executable instruction is stored in the memory 502 and is configured to be executed by the processor 501 to implement the method provided in any embodiment of the present application. The relevant description can be understood by referring to the relevant description and effect corresponding to the steps in the accompanying drawings, and no further elaboration is made here.

[0149] In the embodiment of the present application, the memory 502 and the processor 501 are connected via a bus. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0150] An embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method provided by any embodiment of the present application.

[0151] An embodiment of the present application also provides a computer program product, including computer execution instructions, which implement the method provided by any embodiment of the present application when executed by a processor.

[0152] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.

[0153] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0154] In addition, each functional module in each embodiment of the present application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0155] The program code for implementing the method of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable full-path trajectory fusion device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0156] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0157] In addition, although each operation is described in a specific order, this should be understood as requiring such operation to be performed in the specific order shown or in a sequential order, or requiring that all illustrated operations should be performed to obtain desired results. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the application. Some features described in the context of a separate embodiment can also be implemented in a single implementation in combination. On the contrary, the various features described in the context of a single implementation can also be implemented in multiple implementations individually or in any suitable sub-combination mode.

[0158] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0159] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A mask wearing compliance detection method, characterized in that: include: Obtain the current frame image in the video stream and perform moving target detection on the current frame image; Track the detected moving target and capture the target area image of the same moving target; A trained mask wearing detection model is used to determine whether there is a target face image that does not wear a mask correctly in the target area image; the trained mask wearing detection model is an improved YOLOv5-LITE model; If it is determined that the target face image of the person who is not wearing the mask correctly exists in the target area image, the target area image is sent to the user terminal so that the user terminal warns the user of the behavior of not wearing the mask correctly.

2. The method according to claim 1, characterized in that: The performing moving target detection on the current frame image includes: The ViBe algorithm is used to build a background model for the current frame image in the video stream; The ViBe algorithm is used to perform foreground detection on the current frame image with the established background model, and the foreground area is determined as a moving target.

3. The method according to claim 1, characterized in that The step of tracking the detected moving target and capturing a target area image of the same moving target includes: If it is determined that the moving target enters the pre-set region of interest in the current frame image, a feature-based tracking algorithm or a region-based tracking algorithm is used to track the moving target to obtain the tracking trajectory of the moving target; The moving targets located on the same tracking track are determined as the same moving target, and the target area image of the same moving target is intercepted.

4. The method according to claim 3, characterized in that The method of capturing the target area image of the same moving target comprises: Determine the resolution of the region corresponding to the same moving target in each frame image, and perform expansion processing on the region corresponding to the moving target with a larger resolution to determine the enlarged region corresponding to the moving target; The enlarged corresponding area of ​​the moving target is intercepted by using an external rectangle to obtain the target area image of the same moving target.

5. The method according to claim 1, characterized in that The method of using the trained mask wearing detection model to determine whether there is a target face image in the target area image that does not wear a mask correctly includes: The trained mask wearing detection model is used to detect the human face in the target area image to obtain the category of the human face area in the target area image; the category is: not wearing the mask correctly or wearing the mask correctly; Based on the category of the face area in the target area image, it is determined whether there is a target face image in the current frame image that does not wear a mask correctly.

6. The method according to claim 5, characterized in that Training the mask wearing detection model includes: Obtain a face data set; the face data set includes side face annotated images, occluded face annotated images, small target face image annotated images, and negative sample annotated images; the annotations in the face data set are divided into three categories: wearing a mask in compliance, not wearing a mask in compliance, and not wearing a mask; The mask wearing detection model is trained based on the face data set; the mask wearing detection model includes: an input end, a backbone network, a neck network and a prediction network; the input end of the mask wearing detection model includes an improved mosaic data enhancement operation module; the improved mosaic data enhancement operation module is used to splice every 16 images in the face data set.

7. The method according to claim 6, characterized in that Every 16 images in the face dataset are stitched together, including: Create an initial canvas and divide it into four sub-canvases; Images from four face datasets are respectively spliced ​​in corresponding sub-canvases according to a preset mosaic data enhancement operation mode to form a spliced ​​image consisting of 16 images.

8. The method according to claim 6, characterized in that The input end also includes a Gaussian blur algorithm: the Gaussian blur algorithm is used to perform Gaussian blur processing on the images in the face data set according to a preset ratio, so as to add a blurred face image to the face data set.

9. The method according to claim 6, characterized in that The backbone network in the mask wearing detection model includes: Megvii's lightweight convolutional neural network ShuffleNetv2; the ShuffleNetv2 includes an SE attention module; the SE attention module is used to perform channel feature enhancement processing on the input feature map.

10. The method according to claim 6, characterized in that The neck network in the mask wearing detection model includes: a weighted bidirectional feature pyramid network BiFPN; the weighted bidirectional feature pyramid network is used to perform multi-scale feature fusion processing on input features.

11. A mask wearing compliance detection device, characterized in that: include: A moving target detection module is used to obtain a current frame image in a video stream and perform moving target detection on the current frame image; A moving target tracking module is used to track the detected moving target and capture the target area image of the same moving target; A mask compliance recognition module is used to use a trained mask wearing detection model to determine whether there is a target face image that does not wear a mask correctly in the target area image; the trained mask wearing detection model is an improved YOLOv5-LITE model; The sending module is used to send the target area image to the user terminal if it is determined that the target face image of the person who is not wearing the mask correctly exists in the target area image, so that the user terminal warns the user of the behavior of not wearing the mask correctly.

12. An electronic device, characterized in that: include: A processor, and a memory and a transceiver communicatively connected to the processor; The memory stores computer-executable instructions; the transceiver is used to send and receive data; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 10 when executed by a processor.

Citation Information

Patent Citations

  • Mask wearing monitoring method, electronic equipment and readable storage medium

    CN112395967A

  • Pedestrian tracking and re-identification method based on deep learning

    CN115063836A