Method for detecting off-duty of on-duty personnel based on identity confirmation

By combining the improved YOLOv5 target detection model and the Strongsort multi-target tracking algorithm with the REID algorithm, the problems of high false alarm rate and large human resource demand in detecting on-duty personnel sleeping or leaving their posts have been solved. This has enabled efficient and accurate real-time monitoring and ID confirmation, improving the accuracy and robustness of detection.

CN118608568BActive Publication Date: 2026-11-20BEIJING UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410813133.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2026-11-20
Estimated Expiration
2044-06-24

AI Technical Summary

Technical Problem

Existing methods for detecting on-duty personnel sleeping or leaving their posts have a high false alarm rate and require a large amount of manpower, making it difficult to achieve efficient and accurate real-time monitoring.

Method used

An improved YOLOv5 target detection model is adopted, combined with the Strongsort multi-target tracking algorithm and the REID algorithm. Through identity verification, the detection of sleeping or leaving the post of on-duty personnel is realized. The improved YOLOv5 model structure and loss function are used, combined with the Mosaic data augmentation method to improve the detection accuracy. Trajectory confirmation is performed through three-level matching and Kalman filter, and the ID information of sleeping or leaving the post is output.

Benefits of technology

It improves the accuracy and robustness of sleep deprivation and absence detection, enables real-time tracking of on-duty personnel, reduces false alarm rates, and outputs the ID information of personnel in abnormal states, thereby enhancing the work safety of on-duty personnel and improving corporate efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118608568B_ABST
    Figure CN118608568B_ABST
Patent Text Reader

Abstract

The application provides a method for detecting sleep and leaving of a duty officer based on identity confirmation. The method is based on an improved YOLOv5 target detection model, combined with a multi-target tracking algorithm based on OSnet feature matching, DIoU detection frame matching and Euclidean distance, to realize ID tracking and sleep and leaving judgment of a duty room personnel, construct a sleep and leaving detection model for the duty room personnel, and finally realize real-time detection of identity confirmation and sleep and leaving of the duty officer through the sleep and leaving detection model. Through improvement of the Yolov5 model and the Strongsort network and simultaneous application of the REID algorithm, the design scheme effectively improves the accuracy and robustness of the sleep detection, realizes real-time detection of sleep and leaving of the duty room personnel and output of specific identity information, and has wide application prospects in improving work safety and enterprise benefits.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for detecting on-duty personnel sleeping or leaving their posts based on identity verification, belonging to the field of computer vision and deep learning technology. Background Technology

[0002] When on duty in the control room, staff are prone to fatigue and distraction due to long working hours and repetitive tasks. In such situations, staff may fall asleep or leave their posts, creating safety hazards. To address this, many companies install cameras to monitor the control room, but this often requires significant manpower and has limited effectiveness. We utilize computer vision and deep learning technologies, primarily employing advanced object detection algorithms, to monitor the identity and activities of on-duty personnel in real time, promptly detecting abnormal behaviors such as sleeping or leaving their posts. Once an anomaly is detected, the system immediately issues an alarm, allowing relevant personnel to take timely action.

[0003] Extensive research has been conducted both domestically and internationally on sleep detection, yielding significant results. This research encompasses various techniques and methods, including computer vision, deep learning, and sensor technology. Among these studies, deep learning-based methods have demonstrated excellent feature extraction and classification capabilities, achieving remarkable progress in the field of sleep detection. The YOLO series is a prime example, especially YOLOv5 (You Only Look Once version 5), renowned for its powerful real-time performance, high accuracy, and generalization ability. However, due to the inherent complexity of sleep detection scenarios in duty rooms, relying solely on the YOLOv5 algorithm may result in some undetected or false alarms. Summary of the Invention

[0004] To address the issue of false alarms regarding staff sleeping on duty or leaving their posts in duty rooms, this invention presents a method for detecting staff sleeping on duty or leaving their posts based on identity verification. It employs an improved YOLOv5 target detection model and the Strongsort multi-target tracking algorithm, combined with the REID algorithm, to enhance recognition accuracy and robustness. This makes the judgment of staff sleeping on duty or leaving their posts more accurate, and also allows for ID tracking of staff, outputting the ID identity information of staff sleeping on duty or leaving their posts.

[0005] To achieve the above objectives, this invention designs a method for detecting on-duty personnel sleeping or leaving their posts based on identity verification. According to the detection content of the duty room camera, the following steps are performed to achieve real-time monitoring of on-duty personnel whose identities have been verified sleeping or leaving their posts.

[0006] Step A. Based on the improved YOLOv5 object detection model, the model is trained using images of staff sleeping on duty and working normally in the duty room. Then, the trained model is used to monitor the work of staff in the duty room in real time, output the detection box of the staff, and determine whether they are sleeping or not. Proceed to Step B.

[0007] Step B. Track the on-duty personnel detected by the target detection model. Using the improved Strongsort multi-target tracking algorithm, track the IDs of the on-duty personnel in the two currently detected states, and record the ID information and the sleep label. Proceed to Step C.

[0008] Step C. Judge the matching results. Based on the on-duty personnel objects tracked in the historical frames and the current frame, if the number of consecutive frames in which they are judged to be sleeping on duty exceeds the set threshold for judging sleeping on duty, they are judged to be sleeping on duty. If the number of consecutive frames in which the number of people on duty is less than the set number of people on duty at that time, they are judged to be missing IDs and are judged to be absent from duty.

[0009] As a preferred technical solution of the present invention: Based on the improved YOLOv5 target detection model, the CIOU loss function of YOLOv5 is changed to the MPDloU function. Then, a dataset consisting of each frame of images of a person's sleeping posture and normal working posture is manually labeled. The dataset is expanded and updated by applying the Mosaic data augmentation method to perform sleep status detection and classification. A sleep detection model is pre-trained with images as input and the suspected sleep detection results of preset sleeping and non-sleeping in the images as output.

[0010] As a preferred technical solution of the present invention: the specific design is based on adding an attention SA module to the last layer of the backbone in the YOLOv5 model, thereby forming an improved YOLOv5 model structure that combines the SA attention mechanism.

[0011] The SA module is characterized by high computational efficiency and good performance. It effectively combines the two attention mechanisms mentioned above using a permutation unit. SA first decomposes the input into several groups along the channel dimension, then uses a permutation unit for each group of features to represent the dependence of the features on the spatial domain and channel dimension. Finally, all features communicate with each group of features through channel permutation operations. By using a YOLOv5 model with the SA attention mechanism injected and modifying the loss function to the MPDloU function, the model was trained on the duty room dataset to obtain the object detection model needed for ID tracking, which will be used in the next stage of work.

[0012] In the first stage, the trained YOLOv5 target detection model is used to obtain information such as target detection boxes, categories, and confidence scores for each on-duty personnel in the current image. This information and the corresponding images are then input into the multi-target tracking algorithm, which uses three-level matching to match the predicted trajectory with the detected target.

[0013] First, an adaptive Kalman filter is used to divide the trajectory into confirmed and unconfirmed states. The new trajectory is initially in the unconfirmed state, and it is converted into a confirmed trajectory after three consecutive successful matches. Then, the confirmed trajectory and the target detection box are matched using the feature extractor of the OSNet network. The appearance features of the target are extracted and combined with the motion features output by the Kalman filter. The output shows the successfully matched trajectory, the unmatched trajectory, and the unmatched detection box. For the trajectory and detection box that failed to match in one round, DIoU matching is performed. After the matching is completed, the successfully matched trajectory, the unmatched trajectory, and the unmatched detection box are still output. Finally, the unmatched trajectory and the unmatched detection box are matched according to the principle of minimum Euclidean distance to achieve a third match, which can reduce the tracking error caused by the failure of matching.

[0014] Next, the output results after the three-level matching are analyzed. For successfully matched trajectories, if the target box is in a sleeping state within a set threshold frame number, the person on duty with that ID is determined to be sleeping. If the number of target boxes is less than the current number of people on duty within the set threshold frame number, the person on duty is determined to be missing and thus absent. For trajectories that do not match a target box, if they have exceeded the set maximum retention time and have not been associated, they are deleted. For target boxes that do not match a trajectory, they are used to determine a new trajectory. At the same time, the features of the target box and the features of the absent person are extracted and matched to determine whether they are returning to work. If so, their ID is restored and added to the Kalman filter as a new trajectory for re-evaluation.

[0015] The three-level matching design utilizes OSNet feature matching and DIoU matching to achieve accurate matching of detection boxes and trajectories;

[0016] DIoU considers two metrics: IoU and centroid distance. Their definitions and loss function formulas are as follows:

[0017]

[0018] L DIOU =1-I DIOU

[0019] In the formula: I IOU I is the intersection-union ratio of the predicted bounding box and the detected bounding box. DIOU ρ is the intersection-union ratio (IU) between the predicted bounding box and the detected bounding box. 2 (b,b gt) represents the Euclidean distance between the center points of the detection box and the prediction box, and c represents the diagonal length of the minimum bounding rectangle between the prediction box and the detection box; L DIOU The distance between the predicted bounding box and the detected bounding box is the intersection-union ratio loss.

[0020] The OSnet network is a feature extraction model pre-trained on the Market1501 dataset, used to extract the appearance features of targets.

[0021] The present invention provides a method for detecting sleep deprivation or absence from duty by on-duty personnel based on identity verification. Employing the above technical solution, it achieves the following technical effects:

[0022] (1) The present invention designs a method for detecting sleep and absence of duty personnel based on identity verification. Based on the improved YOLOv5 model structure and the Strongsort multi-target tracking algorithm combined with the REID algorithm, a detection model for detecting sleep and absence of duty personnel in the duty room is constructed to realize real-time tracking and detection of duty personnel. Finally, based on a preset number, the number of consecutive sleep personnel exceeding the set threshold is judged as sleep, and the number of on-duty personnel less than the preset number is judged as absent. For the new trajectory of returning personnel, the REID algorithm is used to update the ID, realizing accurate detection of personnel in the sleep and absence status, and outputting the ID identity information of personnel in abnormal status. The design scheme improves the accuracy and robustness of sleep and absence detection by improving the YOLOv5 model and the Strongsort network and combining them. The addition of the REID algorithm structure makes the ID information more accurate. It has broad application prospects in improving the work safety of duty personnel and the efficiency of enterprises. Attached Figure Description

[0023] Figure 1 This is a flowchart of the method for detecting on-duty personnel sleeping or leaving their posts based on identity verification, as designed in this invention.

[0024] Figure 2 This is a flowchart of the improved Strongsort algorithm in the design of this invention. Detailed Implementation

[0025] The present invention will be further described below with reference to the accompanying drawings.

[0026] This invention proposes a method for detecting on-duty personnel sleeping or leaving their posts based on identity verification. It utilizes an improved YOLOv5 target detection model and the Strongsort multi-target tracking algorithm, combined with the REID algorithm, to enhance recognition accuracy and robustness, making the detection of on-duty personnel sleeping or leaving their posts more accurate. Simultaneously, it outputs the ID information of the on-duty personnel who are sleeping or leaving their posts. Specific steps are as follows: Figure 1 As shown.

[0027] Step A. Based on the improved YOLOv5 object detection model, the model is trained using images of staff sleeping on duty and working normally in the duty room. Then, the trained model is used to monitor the work of staff in the duty room in real time, output the detection box of the staff, and determine whether they are sleeping or not. Proceed to Step B.

[0028] To detect sleep deprivation and absence of duty personnel in the duty room, images of personnel in different postures captured by cameras were used as the dataset. The dataset consisted of manually labeled frames of images in sleeping and non-sleeping postures. Targets in the dataset were labeled with "sleep" and "nosleep" respectively, with the number of data in each category kept equal. The dataset and validation set were divided in an 8:2 ratio. The Mosaic data augmentation method was applied to expand and update the dataset for sleep state detection and classification. The model was trained on a YOLOv5 network to obtain a target detection model for sleep deprivation personnel.

[0029] The CIOU loss function of YOLOv5 is changed to the MPDloU loss function:

[0030] MPDloU is a novel bounding box similarity comparison metric based on minimum point distance. It addresses the problem that existing loss functions cannot effectively optimize when the predicted bounding box and the ground truth bounding box have the same aspect ratio but completely different width and height values. By directly minimizing the distance between the top left and bottom right corners of the predicted bounding box and the actual labeled bounding box, it incorporates all relevant factors considered in existing loss functions, namely overlapping or non-overlapping regions, center point distance, and width and height deviation, while simplifying the calculation process.

[0031]

[0032] L MPDIoU =1-MPDIoU

[0033] That The coordinates of the top-left and bottom-right bounding boxes for the local image targets in the sample images, representing people in sleeping and working states. Let the coordinates of the top-left and bottom-right bounding boxes of the people in the sample images, representing their sleeping and working states, be used. and Let h and w be the squared Euclidean distance between the predicted bounding box and the ground truth bounding box, and let I be the height and width of the sample image. IOU L is the intersection-union ratio (IoU) between the predicted bounding box and the detected bounding box, and MPDIoU is the distance IoU between the predicted bounding box and the detected bounding box. MPDIoU The distance between the predicted bounding box and the detected bounding box is the intersection-union ratio loss.

[0034] In practical applications, the structure of the improved YOLOv5 model is specifically designed by adding an attention-connected improved SA module to the last layer of the backbone in the YOLOv5 model, thus forming an improved YOLOv5 model structure that combines the SA attention mechanism.

[0035] First, for a given feature map X∈R C×H×W Where C, H, and W are the number of channels, spatial height, and width, respectively. SA is first divided into G groups along the channel dimension X, where X = [X1, ..., X...]. G ], xk ∈R C|G×H×W During training, each sub-feature X k Gradually acquire a semantic response, then use an attention module to generate a corresponding importance coefficient for each sub-feature. At the beginning of any attention unit, X... k The input will be split into two branches X along the channel dimension. k1 ,X k2 ∈R C / 2G×H×W The input data is processed through two branches. The first branch X k1 Focus on the relationships between channels and generate a channel attention map to highlight important channel information. Second branch X k2 Focusing on the spatial relationships of features, a spatial attention map is generated to highlight important spatial information. The outputs of these two branches are concatenated to ensure that the number of channels matches the number of channels in the input data. Finally, all features are aggregated along the channel dimension to enable cross-group communication, allowing the model to more effectively understand and process the input data.

[0036]

[0037] X′ k1 =σ(W1s+b1)·X k1

[0038] X′ k2 =σ(W2·GN(X) k2 )+b2)·X k2

[0039] Channel attention X′ k1 Spatial attention X′ k2 The outputs are represented as shown in the above equations, where W1∈R C / 2G×1×1 and b1∈R C / 2G×1×1 The parameters used for scaling and translation channel statistics s, GN is the Group Norm used to obtain spatial statistics, while W2, b2 are parameters of shape R C / 2G×1×1 The parameters are σ, where σ is the sigmoid activation function.

[0040] After completing the first two attention calculations, they need to be integrated: Xk = [X′] K1 ,X′ K2 ]∈R C / G×H×W Finally, channel permutation is used to share information between different groups, so that the final output of SA is consistent with the input size.

[0041] The default G value for SA is 64. Experiments showed that dividing the feature maps into 32 groups yielded better results for our dataset, while also maintaining parameter reduction. Therefore, the specific process for improving the SA algorithm with G=32 is as follows:

[0042] 1) Input feature map X, and divide it into 32 groups along the channel size, i.e., X = [X1, ..., X2]. 32 Furthermore, each group X gradually captures specific semantic responses during the training process;

[0043] 2) Divide each group X into two parts, one part using channel attention and the other part using spatial attention;

[0044] 3) Overlay the two parts according to the number of channels to achieve information fusion within the group;

[0045] 4) Perform a random mixing operation on all X to enable information flow between different groups;

[0046] 5) Output feature map.

[0047] Step B. Track the on-duty personnel detected by the target detection model. Using the improved Strongsort multi-target tracking algorithm, track the IDs of the on-duty personnel in the two currently detected states, and record the ID information and the sleep label. Proceed to Step C.

[0048] The specific process of the improved Strongsort multi-target tracking algorithm described in step B is as follows: Figure 2 As shown, the target detection model in step A is used to detect the target bounding box, category, confidence score and other information of the target in each frame of the image. This information and the corresponding image are input into the multi-target tracking algorithm, and the predicted trajectory and the detected target are matched through three-level matching.

[0049] For the first-level matching, the algorithm considers two branches: appearance features and motion features. Strongsort applies the appearance feature extractor BOT to the appearance branch; we replace it with an OSNet network to extract features. This model, pre-trained on the Market1501 dataset, can extract more discriminative features. Simultaneously, a feature update strategy is used to update the appearance state of the i-th trajectory at frame t using an exponential moving average (EMA). As shown below:

[0050]

[0051] Among them, f i t This is the appearance embedding of the current OSnet network detection, where 'a' is the momentum term, which we set to 0.9. The EMA update strategy not only improves matching quality but also reduces time consumption.

[0052] Where R k It is a pre-set constant measurement noise covariance, obtained by scaling the measured state vector, and is set to (0.5*h, 0.5*h, 0.1, 0.5*h), c k It is the detection confidence score under state k;

[0053] In the matching process, instead of using only appearance feature distance, both appearance and motion information are considered simultaneously. The cost matrix C is the appearance cost A. a and sports costs A m The weighted sum is as follows:

[0054] C=λA a +(1-λ)A m

[0055] The weighting factor λ is set to 0.98.

[0056] After the first level of matching, the algorithm outputs successfully matched trajectories, unmatched trajectories, and unmatched detection boxes. When feature matching fails to match the predicted box, the algorithm automatically performs IoU matching with the original detection box to determine their final matching status. Traditional IoU (Intersection over Union) only considers the overlap between the predicted and detection boxes, without considering the distance between them. When the target cannot be matched through feature matching and there is no overlapping area between the predicted and detection boxes, it will lead to a change in the tracking number. To solve this problem, we use DIoU (Distance Intersection over Union) instead of IoU. DIoU considers not only the degree of overlap but also the distance information between the target boxes, thus more comprehensively evaluating the matching status. DIoU considers two metrics: IoU and center point distance. Their definitions and loss function formulas are as follows:

[0057]

[0058] L DIOU =1-I DIOU

[0059] In the formula: I IoUI is the intersection-union ratio of the predicted bounding box and the detected bounding box. DIOU p is the intersection-union ratio (IU) between the predicted bounding box and the detected bounding box. 2 (b,bg t ) represents the Euclidean distance between the center points of the detection box and the prediction box, and c represents the diagonal length of the minimum bounding rectangle between the prediction box and the detection box; L DIoU The distance between the predicted bounding box and the detected bounding box is the intersection-union ratio loss.

[0060] Although Strongsort's second-level matching can match correctly in most cases, there are still cases of missed detections and false detections. Therefore, we add a third Euclidean distance matching. After the second-level matching, we still output the successfully matched trajectory, the unmatched trajectory, and the unmatched detection box. We then match the unmatched trajectory and unmatched detection box according to the principle of minimum Euclidean distance, which reduces tracking errors caused by matching failures. We add the third matching after feature matching and detection box matching, and then match based on the Euclidean distance between the center point of the previously successfully matched target box and the center point of the currently unmatched target detection box. The formula for calculating the distance D is as follows:

[0061]

[0062] In the formula (x i ,y i Let be the center point of the bounding box of the i-th unmatched track when it was last successfully matched.

[0063] (x j ,y j ) represents the center point location of the j-th unmatched detection.

[0064] After the three-level matching is completed, the matching results are output. We then classify and analyze the results to determine whether someone is absent from their post or sleeping on duty.

[0065] Step C. Judge the matching results. Based on the on-duty personnel objects tracked in the historical frames and the current frame, if the number of consecutive frames in which they are judged to be sleeping on duty exceeds the set threshold for judging sleeping on duty, they are judged to be sleeping on duty. If the number of consecutive frames in which the number of people on duty is less than the set number of people on duty at that time, they are judged to be missing IDs and are judged to be absent from duty.

[0066] After the three-level matching is completed, we obtain the output results and analyze them. For successfully matched trajectories, if the category detection results of the same target are all "sleep" within a set threshold frame number of 50 frames, then the staff member with that ID is judged to be sleeping on duty. If the number of successfully matched trajectories within the set threshold frame number of 50 frames is less than the current number of staff members on duty, then the staff member with the missing ID is judged to be absent from duty. For trajectories that do not match the target box, if they are not associated after exceeding the set maximum number of unmatched frames max_age, they are deleted. We initially set it to 30 frames. For the target boxes of unmatched trajectories, we judge them as new trajectories. At the same time, we use the feature extractor to extract the features of the new target and match them with the features in the absent staff feature library to determine whether the absent staff member has returned to work. We keep the IDs from being confused and add them as new trajectories to the Kalman filter for re-judgment.

[0067] In the three-level matching process, for personnel identified as having left their posts, their appearance features from the previous 50 frames are saved separately before deleting their trajectories, forming a feature library for those who have left their posts. We save the features of these personnel according to their IDs to form this feature library. When a new target appears, primarily manifested as an unmatched bounding box, we use the OSNet network to extract its features. We then fuse the features from the last 50 frames of the previously saved images of the personnel who left their posts and match them with the features of the new target. We use the cosine distance between the features to determine if the target is a returning employee. If so, the unmatched bounding box is deleted, and the new trajectory is added to the tracking trajectory, maintaining the same ID information as before leaving the post, thus implementing the REID function. Furthermore, the number of personnel in the duty room is synchronously fixed based on the number of people clocking in. When the number of existing trajectories equals the total number of people clocking in that day, the last unmatched bounding box is deleted, and no new trajectories are added.

[0068] For outputting personnel ID information, each ID corresponds to the employee's name and other identity information. Employees need to clock in when they first enter the duty room each day. The clock-in process assigns an ID and records the employee's identity information. For the ID tracking process, we control ID updates and determine absences based on the total number of IDs clocked in each day. The current number of clocked-in employees is the number of employees who should be on duty. If the number of employees clocked in is less than the current number of employees on duty within a set threshold of 50 frames, it is considered that there are missing personnel and that they have left their posts. When a new target appears, if the current number of employees is equal to the total number of employees on duty, it is considered a stranger and is not tracked.

[0069] Finally, an improved YOLOv5 object detection and multi-object tracking algorithm was integrated to construct a sleep deprivation / absence detection system. First, the sleep deprivation dataset was divided into training, validation, and test sets according to a certain ratio for model training, tuning, and testing. When evaluating the detection algorithm's performance, we selected multiple performance metrics, including mean precision, accuracy, recall, and F1 score, to comprehensively assess the algorithm's effectiveness. Furthermore, we conducted comparative experiments with other sleep deprivation detection algorithms, including traditional feature extraction-based methods and deep learning-based methods, ensuring a fair comparison. Through analysis of the experimental results, we evaluated the detection accuracy and efficiency of this method under different sleep deprivation states, as well as its applicability and generalization ability on different datasets, providing a comprehensive and effective solution for sleep deprivation detection tasks.

[0070] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes and modifications can be made without departing from the spirit of the present invention. These changes and modifications can involve various aspects, including but not limited to algorithm design, system construction, parameter adjustment, etc. Therefore, the specific embodiments of the present invention can be appropriately adjusted and improved according to actual needs and specific circumstances to achieve better performance, efficiency, or applicability.

Claims

1. A method for detecting sleep deprivation and absence from duty by on-duty personnel based on identity verification, characterized in that... Includes the following steps: Step A. Based on the improved YOLOv5 target detection model, the model is trained using images of staff sleeping on duty and working normally in the duty room. Then, the trained model is used to monitor the work of staff in the duty room in real time, output the detection box of the staff, and determine the detection results of sleeping on duty and not sleeping on duty. Proceed to Step B. Step B. Track the on-duty personnel detected by the target detection model. Using the improved Strongsort multi-target tracking algorithm, track the IDs of the on-duty personnel in the two detected states, and record the ID information and the sleep label. Proceed to Step C. Step C. Judge the matching results. Based on the on-duty personnel objects tracked in the historical frames and the current frame, if the number of consecutive frames in which they are judged to be sleeping on duty exceeds the set threshold for judging sleeping on duty, they are judged to be sleeping on duty. If the number of consecutive frames in which the number of people on duty is less than the set number of people on duty at that time, they are judged to be missing IDs and are judged to be absent from duty. The specific steps are as follows: Step A. Based on the YOLOv5 object detection model, the model is trained using images of staff sleeping on duty and working normally in the duty room. Then, the trained model is used to monitor the work of staff in the duty room in real time, output the detection box of the staff, and determine whether they are sleeping on duty or not. Proceed to Step B. To detect sleeping or absenteeism of duty personnel in the duty room, images of personnel in different postures captured by cameras were used as a dataset. The dataset consisted of frames of images of people in sleeping and non-sleeping postures. The targets in the dataset were labeled with "sleep" and "nosleep" respectively. The number of data in the two categories was kept equal during the labeling process. The dataset and validation set were also divided. The model was trained on the YOLOv5 network structure to obtain a target detection model for sleeping personnel. The CIOU loss function of YOLOv5 is changed to the MPDloU loss function: ; ; That( ), ( ) represents the coordinates of the top-left and bottom-right bounding boxes of the local image targets in the sample image, representing the sleeping and working states. ), ( ( ) represents the top-left and bottom-right coordinates of the ground truth bounding boxes for people in sleeping and working states in the sample images. and Let h and w be the squared Euclidean distance between the predicted bounding box and the ground truth bounding box, and h and w be the height and width of the sample image, respectively. The intersection-union ratio (IUU) of the predicted bounding boxes and the detected bounding boxes. The intersection-over-union ratio (IoU) is the distance between the predicted bounding box and the detected bounding box. The intersection-union (IoU) loss is calculated by comparing the distances between the predicted bounding box and the detected bounding box. In the YOLOv5 model, an improved SA (Attention Constraint) module is added to the last layer of the backbone, forming an improved YOLOv5 model structure that incorporates the SA attention mechanism, as follows: First, for a given feature map ,in These are the number of channels, the height of the space, and the width. First, divide the channel into G groups along the channel dimension X. During training, each sub-feature Gradually acquire a semantic response, and then use an attention module to generate a corresponding importance coefficient for each sub-feature. At the beginning of any attention unit, The input will be split into two branches along the channel dimension. The input data is processed through two branches; the first branch... Focusing on the relationships between channels, a channel attention map is generated to emphasize important channel information; the second branch Focusing on the spatial relationships of features, a spatial attention map is generated to highlight important spatial information; the outputs of these two branches are concatenated to ensure that the number of channels matches the number of channels in the input data; finally, all features are aggregated along the channel dimension. ; Channel attention and spatial attention The outputs are represented as shown in the above equations, where, The parameter used for scaling and translation channel statistics s, GN stands for Group Norm, used to obtain spatial statistics. , It is shaped as The parameters, Use the Sigmoid activation function; After completing the first two attention calculations, they need to be integrated. Finally, channel permutation is used to share information between different groups, so that the final output of SA is consistent with the input size; The default G value for SA is 64. The specific process of improving the SA algorithm with G value of 32 is as follows: 1) Input feature map X, divide it into 32 groups along the channel size, i.e. Furthermore, each group X gradually captures specific semantic responses during the training process; 2) Divide each group X into two parts: one part uses channel attention, and the other part uses spatial attention; 3) The two parts are overlaid according to the number of channels to achieve information fusion within the group; 4) Perform a random mixing operation on all X values ​​to enable information flow between different groups; 5) Output feature map; Step B. Track the on-duty personnel detected by the target detection model. Using the improved Strongsort multi-target tracking algorithm, track the IDs of the on-duty personnel in the two detected states, and record the ID information and the sleeping post label. Proceed to Step C. Three-level matching is used to match the predicted trajectory with the detected target; For the first-level matching, the algorithm considers two branches: appearance features and motion features. Strongsort applies the appearance feature extractor BOT to the appearance branch, replacing it with an OSNet network to extract features. It then uses a feature update strategy to update the appearance state of the i-th trajectory at frame t using an exponential moving average (EMA). As shown below: ; in, It is the current appearance embedding of OSnet network detection. This is the momentum term, set to 0.9; For the motion feature part, ECC is used for camera motion compensation, and the NSA Kalman algorithm is used. It consists of a state estimation step and a state update step. First, the current state variables and their uncertainties are generated. Then, these estimates are updated with a weighted average of the estimated states and the measured values. Here, the state vector is an 8-dimensional vector. ,in This indicates the coordinates of the center point of the trajectory rectangle. The aspect ratio of the frame. The height of the frame. express Velocity in the image coordinate system; The NSA Kalman algorithm proposes an adaptive method for calculating noise covariance. The formula: ; in It is a pre-set constant measurement noise covariance, obtained by scaling the measured state vector, and is set to (0.5*h, 0.5*h, 0.1, 0.5*h). It is the detection confidence score under state k; The matching process no longer uses only appearance feature distance, but considers both appearance and motion information simultaneously, and the cost matrix... It is the cost of appearance. and sports costs The weighted sum is as follows: ; The weighting factor λ is set to 0.

98. After the first level of matching, the algorithm outputs successfully matched trajectories, unmatched trajectories, and unmatched detection boxes. When feature matching fails to match the predicted box, the algorithm automatically performs IoU matching with the original detection box to determine their final matching status. DIoU (Distance Intersection over Union) is used instead of IoU. DIoU considers two metrics: IoU and center point distance. Its definition formula and loss function formula are as follows: ; In the formula: The intersection-union ratio (IUU) of the predicted bounding boxes and the detected bounding boxes. The intersection-over-union ratio (IoU) is the distance between the predicted bounding box and the detected bounding box. Let c be the Euclidean distance between the center points of the detection box and the prediction box, and let c be the diagonal length of the minimum bounding rectangle between the prediction box and the detection box. The intersection-union (IoU) loss is calculated by comparing the distances between the predicted bounding box and the detected bounding box. After the second-level matching, the system still outputs successfully matched trajectories, unmatched trajectories, and unmatched detection boxes. The unmatched trajectories and unmatched detection boxes are then matched according to the principle of minimum Euclidean distance. A third matching step is added after feature matching and detection box matching. This step calculates the Euclidean distance between the center point of the previously successfully matched target box and the center point of the currently unmatched target detection box. The calculation formula is as follows: ; In the formula Let i be the center point of the bounding box of the i-th unmatched track when the last successful match occurred. The location of the center point of the j-th unmatched detection. After the three-level matching is completed, the matching results are output, and the results are classified and analyzed to determine whether the employee is absent from duty or sleeping on duty. Step C. Judge the matching results. Based on the on-duty personnel objects tracked in the historical frames and the current frame, if the number of consecutive frames in which they are judged to be sleeping on duty exceeds the set threshold for judging sleeping on duty, they are judged to be sleeping on duty. If the number of consecutive frames in which the number of people on duty is less than the set number of people on duty at that time, they are judged to be missing IDs and are judged to be absent from duty. After the three-level matching is completed, the output results are obtained and analyzed. For successfully matched trajectories, if the category detection results for the same target are all "sleep" within a set threshold of 50 frames, the staff member with that ID is judged to be asleep on duty. If the number of successfully matched trajectories within the set threshold of 50 frames is less than the current number of staff on duty, the staff member with the missing ID is judged to be absent from duty. For trajectories that do not match the target box, if they exceed the set maximum number of unmatched frames (max_age) and are not associated, they are deleted. The initial setting is 30 frames. For the target boxes of unmatched trajectories, they are judged as new trajectories. At the same time, the feature extractor is used to extract the features of the new target and match them with the features in the absent staff feature library to determine whether the absent staff member has returned to work, keeping the IDs intact. These new trajectories are then added to the Kalman filter for further judgment. In the three-level matching process, for personnel who have left their posts, their appearance features from the previous 50 frames are saved separately before their trajectories are deleted, forming a feature library for those who have left their posts. The features of these personnel are also saved according to their IDs, forming another feature library for those who have left their posts. When a new target appears, primarily manifested as an unmatched bounding box, its features are extracted using the OSNet network. The features from the last 50 frames of the previously saved images of the personnel who left their posts are fused and then matched with the features of the new target. The cosine distance between the features is used to determine if the target is a returning employee. If so, the unmatched bounding box is deleted, and the new trajectory is added to the tracking trajectory, maintaining the same ID information as before the departure. Furthermore, the number of personnel in the duty room is fixed synchronously based on the number of people clocking in. When the number of existing trajectories equals the total number of people clocking in that day, the last unmatched bounding box is deleted, and no new trajectories are added. For outputting personnel ID information, each ID corresponds to the employee's name and other identity information. Employees need to clock in when they first enter the duty room each day. The clock-in process assigns them an ID and records their identity information. For the ID tracking process, the total number of IDs for the daily clock-in is used to control ID updates and determine whether someone is off duty. The current number of clock-in is the number of people who should be on duty. If the number of clock-in is less than the current number of people on duty within a set threshold of 50 frames, it is determined that there are missing personnel and that they are off duty. When a new target appears, if the current number of people is equal to the total number of people on duty, it is determined to be a stranger and will not be tracked.

Citation Information

Patent Citations

  • Grain depot vehicle tracking method based on YOLOv5 and improved StrongSORT

    CN116580333A

  • Improved YOLOv5-based sleep post detection method

    CN116597281A