On-duty personnel sleep and departure detection method based on identity confirmation
By combining the improved YOLOv5 model with the Strongsort and REID algorithms, the problem of false alarms in the detection of sleeping and leaving work in the duty room is solved, the accurate tracking and identity confirmation of the personnel on duty is achieved, and the accuracy and robustness of the detection are improved. The safety of personnel on duty and corporate efficiency are ensured.
Patent Information
- Application Number
- CN202410813133.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-24
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-06-24
AI Technical Summary
The existing technology has false alarms in the detection of sleeping and off-duty in the duty room. The YOLOv5 algorithm has limited recognition effect in complex scenarios, making it difficult to accurately determine the sleeping or off-duty status of the on-duty personnel.
Using the improved YOLOv5 target detection model combined with the Strongsort multi-target tracking algorithm and REID algorithm, through the training model and data set expansion, adding SA attention module and DIoU matching, real-time tracking and identity confirmation of personnel on duty can be achieved, and the accuracy of detection can be improved. and robustness.
It has significantly improved the accuracy and robustness of sleep-on-duty and off-duty detection, and can accurately determine the on-duty personnel's sleeping or off-duty status, and output relevant ID information, which enhances the work safety of on-duty personnel and corporate benefits.
Smart Images

Figure CN118608568A
Abstract
Description
Technical Field
[0001] The present invention relates to a method for detecting on-duty personnel sleeping or leaving their posts based on identity confirmation, and belongs to the technical field of computer vision and deep learning. Background Art
[0002] When the duty personnel are working in the duty room, they are prone to fatigue and distraction due to their long working hours and single work content. In this case, the duty personnel may sleep at their posts or leave their posts, which may cause safety hazards. In order to deal with this problem, many companies install cameras to monitor the situation in the duty room, but this often requires a lot of manpower and the monitoring effect is limited. We use computer vision and deep learning technology, mainly using advanced target detection algorithms, to monitor the identity and activities of duty personnel in real time, and promptly detect abnormal behaviors such as sleeping or leaving their posts. Once an abnormality is detected, the system will immediately issue an alarm so that relevant personnel can take timely measures.
[0003] At present, there have been a lot of studies on post-sleeping detection at home and abroad, and certain research results have been achieved. These studies cover various technical means and methods, including computer vision, deep learning, and sensor technology. Among these studies, deep learning-based methods have shown excellent feature extraction and classification capabilities, and have made significant progress in the field of post-sleeping detection. The YOLO series is one of the representatives, especially YOLOv5 (You Only Look Once version 5), which is known for its strong real-time performance, high accuracy and generalization ability. However, due to the complexity of the duty room staff sleeping on duty and leaving the post detection scenario, relying solely on the YOLOv5 algorithm may result in some undetected or false positives. Summary of the invention
[0004] In order to solve the false alarm problem of sleeping or leaving the post in the duty room, the present invention designs a detection method for sleeping or leaving the post of duty personnel based on identity confirmation. The improved YOLOv5 target detection model and Strongsort multi-target tracking algorithm are combined with the REID algorithm to improve the recognition accuracy and robustness, so that the judgment of sleeping or leaving the post of duty personnel is more accurate. At the same time, the ID of the duty personnel can be tracked and the ID identity information of the sleeping or leaving the post of duty personnel can be output.
[0005] To achieve the above objectives, the present invention designs a method for detecting on-duty personnel sleeping on duty or leaving their posts based on identity confirmation. According to the detection content of the duty room camera, the following steps are performed to realize real-time monitoring of on-duty personnel sleeping on duty or leaving their posts with confirmed identities.
[0006] Step A. Based on the improved YOLOv5 target detection model, the model is trained using images of duty room personnel sleeping on duty and images of normal working on duty. The trained model is then used to monitor the work of duty room personnel in real time, output the detection frame of the duty personnel, determine the detection results of sleeping on duty and non-sleeping on duty, and proceed to step B.
[0007] Step B. Track the on-duty personnel detected by the target detection model, use the improved Strongsort multi-target tracking algorithm to track the IDs of the on-duty personnel in the two currently detected states, and record the ID information and sleeping labels, and then proceed to step C.
[0008] Step C. judge the matching results based on the on-duty personnel objects tracked by the historical frames and the current frames. If the number of consecutive frames of the on-duty personnel exceeds the set threshold for judging sleeping on duty, the on-duty personnel is judged to be sleeping on duty. If the number of consecutive frames of the number of on-duty personnel is less than the set number of on-duty personnel at that time, the on-duty personnel is judged to be missing ID and off-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, and then a data set consisting of each frame image of a person's sleeping posture and normal working posture is manually marked, and the data set is expanded and updated in combination with the Mosaic data enhancement method to perform sleeping guard state detection and classification, and a sleeping guard detection model is pre-trained with images as input and the suspected sleeping guard detection results of preset sleeping and non-sleeping in the image as output.
[0010] As a preferred technical solution of the present invention: a specific design is to add an attention SA module to the last layer of the backbone in the YOLOv5 model to form an improved YOLOv5 model structure combined with the SA attention mechanism.
[0011] The SA module has the characteristics of high computational efficiency and good effect. It uses the permutation unit to effectively combine the above two types of attention mechanisms. SA first decomposes the input into several groups along the channel dimension, and then uses the permutation unit for each group of features to express the degree of dependence of the features on the spatial domain and channel dimensions. Finally, all features are permuted by the channel to achieve communication between each group of features. By using the YOLOv5 model injected with the SA attention mechanism and modifying the loss function to the MPDloU function, the model is trained for the duty room data set, and the target detection model required for the subsequent ID tracking is obtained, and the next stage of work is carried out:
[0012] In the first stage, the trained YOLOv5 target detection model is used to obtain the target detection box, category, confidence and other information of each on-duty personnel in the current 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;
[0013] First, the adaptive Kalman filter is used to divide the trajectory into a confirmed state and an unconfirmed state. The new trajectory is set to an unconfirmed state by default. The unconfirmed state is converted to a confirmed state trajectory after three consecutive successful matches. Then, the confirmed state trajectory and the target detection frame are matched based on the feature extractor of the OSnet network, and the appearance features of the target are extracted and combined with the motion features output by the Kalman filter. The output is the successfully matched trajectory, the unmatched trajectory, and the unmatched detection frame. DIoU matching is performed on the trajectory and detection frame that failed to match in one round. After the matching is completed, the successfully matched trajectory, the unmatched trajectory, and the unmatched detection frame are still output. Finally, the unmatched trajectory and the unmatched detection frame are matched according to the principle of minimum Euclidean distance to achieve the third matching, which can reduce the tracking error problem caused by matching failure.
[0014] Then, the output results after the three-level matching are analyzed, and the successfully matched trajectories are analyzed. If the target frame is in the sleeping state within the set threshold number of frames, the ID on-duty personnel is judged to be sleeping on duty. If the number of people on duty is less than the current number of people on duty within the set threshold number of frames, it is judged that the ID person is missing and is off duty; for the trajectory that is not matched to the target frame, when it exceeds the set maximum storage time and is not associated, it will be deleted; for the target frame that is not matched to the trajectory, it will be judged as a new trajectory, and the target features and off-duty personnel features will be extracted and matched to determine whether it is a returning employee. If so, its ID will be restored and added to the Kalman filter as a new trajectory to continue to re-judge.
[0015] The three-level matching design uses OSnet-based feature matching and DIoU matching to achieve accurate matching of detection boxes and trajectories.
[0016] DIoU considers two indicators, IoU and center point distance. Its definition formula and loss function formula are as follows:
[0017]
[0018] L DIOU =1-I DIOU
[0019] Where: I IOU is the intersection-over-union ratio of the predicted box and the detection, I DIOU is the intersection-over-union ratio of the distance between the prediction box and the detection box, ρ 2 (b,b gt) is the Euclidean distance between the center point of the detection box and the prediction box, c is the diagonal length of the minimum circumscribed rectangle of the prediction box and the detection box; L DIOU It is the distance intersection loss between the prediction box and the detection box.
[0020] The OSnet network is a feature extraction model pre-trained on the Market1501 dataset, which is used to extract the appearance features of the target.
[0021] The method for detecting on-duty personnel sleeping on duty or leaving their posts based on identity confirmation of the present invention adopts the above technical scheme and has the following technical effects:
[0022] (1) The present invention designs a method for detecting on-duty personnel sleeping or leaving their posts based on identity confirmation. Based on the improved YOLOv5 model structure and the Strongsort multi-target tracking algorithm and combined with the REID algorithm, a detection model for detecting on-duty personnel sleeping or leaving their posts is constructed to realize real-time tracking and detection of on-duty personnel. Finally, based on a preset number, continuous sleeping personnel exceeding a set threshold are judged as sleeping on their posts, and on-duty personnel less than a preset number are judged as off-duty. The REID algorithm is used to update the ID of the new trajectory of the returning personnel to realize accurate detection of people in the sleeping or leaving status, and the ID identity information of the abnormal status personnel is output at the same time. The design scheme improves the Yolov5 model and the Strongsort network and their joint application, effectively improving the accuracy and robustness of the detection of sleeping or leaving the post. The addition of the REID algorithm structure makes the ID information more accurate, which has broad application prospects in improving the work safety of on-duty personnel and the benefits of enterprises. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a flow chart of a method for detecting on-duty personnel sleeping or leaving their posts based on identity confirmation designed by the present invention;
[0024] Figure 2 It is a flow chart of the improved Strongsort algorithm in the design of the present invention. DETAILED DESCRIPTION
[0025] The present invention will be further described below in conjunction with the accompanying drawings.
[0026] The present invention proposes a detection method for on-duty personnel sleeping or leaving their posts based on identity confirmation. The improved YOLOv5 target detection model and the Strongsort multi-target tracking algorithm are combined with the REID algorithm to improve the recognition accuracy and robustness, so that the judgment of on-duty personnel sleeping or leaving their posts is more accurate, and the ID information of the on-duty personnel sleeping or leaving their posts is output. The specific steps are as follows: Figure 1 shown.
[0027] Step A. Based on the improved YOLOv5 target detection model, the model is trained using images of duty room personnel sleeping on duty and images of normal working on duty. The trained model is then used to monitor the work of duty room personnel in real time, output the detection frame of the duty personnel, determine the detection results of sleeping on duty and non-sleeping on duty, and proceed to step B.
[0028] For the detection of sleeping and leaving the duty room personnel, the images of different postures of the duty room personnel are collected by the camera as the dataset. The dataset consists of manually marked frames of images of the sleeping and non-sleeping postures of the characters. The targets in the dataset are labeled as "sleep" and "nosleep" respectively. The number of datasets of the two categories is kept equal during labeling. The dataset and the validation set are divided into 8:2 ratio. The Mosaic data enhancement method is used to expand and update the dataset for sleep state detection and classification. The YOLOv5 network structure is trained to obtain the target detection model for sleeping personnel.
[0029] The CIOU loss function of YOLOv5 is changed to MPDloU loss function:
[0030] MPDloU is a new bounding box similarity comparison metric based on minimum point distance. It solves the problem that the existing loss function cannot be effectively optimized when the predicted bounding box and the true bounding box have the same aspect ratio but completely different width and height values. By directly minimizing the distance between the upper left and lower right corners of the predicted bounding box and the actual annotated bounding box, it includes all relevant factors considered in the existing loss function, namely overlapping or non-overlapping areas, center point distance, width and height deviation, while simplifying the calculation process.
[0031]
[0032] L MPDIoU =1-MPDIoU
[0033] That The upper left and lower right coordinates of the local image prediction box of the target person in the sleeping state and the working state in the sample image, are the upper left and lower right coordinates of the real boxes of the target persons in the sleeping and working states in the sample image, and is the squared Euclidean distance between the predicted box and the true box, h and w are the height and width of the sample image, and I IOU is the intersection-over-union ratio of the predicted box and the detected box, MPDIoU is the intersection-over-union ratio of the distance between the predicted box and the detected box, L MPDIoU It is the distance intersection loss between the prediction box and the detection box.
[0034] In practical applications, the structure of the improved YOLOv5 model is specifically designed based on adding an attention-connected improved SA module to the last layer of the backbone of the YOLOv5 model to form an improved YOLOv5 model structure combined with 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 the training process, each sub-feature X k Gradually obtain a semantic response, and then use the 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 divided into two branches along the channel dimension X k1 ,X k2 ∈R C / 2G×H×W , through two branches to process the input data. The first branch X k1 Focus on the relationship between channels and generate channel attention maps to emphasize important channel information. The second branch X k2 Focusing on the spatial relationship of features, a spatial attention map is generated to highlight important spatial information. The outputs of these two branches are concatenated together to ensure that the number of channels matches the number of channels of the input data. Finally, all features are aggregated along the channel dimension to achieve cross-group information exchange, allowing the model to understand and process the input data more effectively.
[0036]
[0037] X′ k1 =σ(W1s+b1)·X k1
[0038] X′ k2 =σ(W2·GN(X k2 )+b2)·X k2
[0039] Channel attention X′ k1 and spatial attention X′ k2 The output representations are shown in the above formula, where W1∈R C / 2G×1×1 and b1∈R C / 2G×1×1 Parameters for scaling and translating channel statistics s, GN is Group Norm, used to obtain spatial statistics, and W2, b2 are shapes of R C / 2G×1×1 Parameters of . σ is the Sigmoid activation function.
[0040] After completing the first two attention calculations, we need to integrate them, Xk = [X′ K1 ,X′ K2 ]∈R C / G×H×W ,Finally, the channel permutation operation 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 of SA is 64. After experiments, for our data set, dividing the feature map into 32 groups has a better effect, while also keeping the parameters low. Therefore, the specific process of improving the SA algorithm with G as 32 is as follows:
[0042] 1) Input feature map X and divide it into 32 groups along the channel dimension, that is, X = [X1,…,X 32 ], and each group of X gradually captures a specific semantic response during the training process;
[0043] 2) Divide each group X into two parts, one using channel attention and the other using spatial attention;
[0044] 3) Superimpose the two parts according to the number of channels to achieve information fusion within the group;
[0045] 4) Perform random mixing operations 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, use the improved Strongsort multi-target tracking algorithm to track the IDs of the on-duty personnel in the two currently detected states, and record the ID information and sleeping labels, and then 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 detection box, category, confidence and other information of the target in each frame image, and 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 the OSnet network to extract features. This model is pre-trained on the Market1501 dataset and can extract more discriminative features. At the same time, the feature update strategy is used to update the appearance state of the i-th track at frame t in an exponential moving average (EMA) manner. As shown below:
[0050]
[0051] Among them, f i t is the appearance embedding of the current OSnet network detection, a is the momentum term, which we set to 0.9, and the EMA update strategy not only improves the matching quality but also reduces the time consumption.
[0052] Where R k is the preset constant measurement noise covariance, which is obtained by scaling the measured state vector and is set to (0.5*h, 0.5*h, 0.1, 0.5*h), c k is the detection confidence score in state k;
[0053] In the matching process, the appearance feature distance is no longer used alone, but the appearance and motion information are considered at the same time. The cost matrix C is the appearance cost A a and the movement cost A m The weighted sum of is as follows:
[0054] C=λA a +(1-λ)A m
[0055] The weight factor λ is set to 0.98;
[0056] After the first level of matching is completed, the successfully matched trajectories, unsuccessfully matched trajectories, and unsuccessfully matched detection frames are output. When the feature matching cannot successfully match the predicted frame, the algorithm will automatically perform IoU matching with the original detection frame to determine their final matching status. The traditional IoU (Intersection over Union) only considers the degree of overlap between the predicted box and the detection box, but does not consider the distance between them. When the target cannot be matched through feature matching, and there is no overlapping area between the predicted box and the detection box, it will cause a change in the tracking number. To solve this problem, we use DIoU (Distance Intersection over Union) instead of IoU. DIoU not only considers the degree of overlap, but also the distance information between the target boxes, so as to more comprehensively evaluate the matching status. DIoU considers two indicators, IoU and center point distance. Its definition formula and loss function formula are as follows:
[0057]
[0058] L DIOU =1-I DIOU
[0059] Where: I IoUis the intersection-over-union ratio of the predicted box and the detection, I DIOU is the intersection-and-union ratio of the distance between the prediction box and the detection box; p 2 (b,bg t ) is the Euclidean distance between the center point of the detection box and the prediction box, c is the diagonal length of the minimum circumscribed rectangle of the prediction box and the detection box; L DIoU It is the distance intersection loss between the prediction box and the detection box.
[0060] Although Strongsort's secondary matching can correctly match in most cases, there are still cases of missed detection and false detection, so we add a third Euclidean distance matching. After the secondary matching is completed, the matched trajectory, unmatched trajectory, and unmatched detection frame are still output. We match the unmatched trajectory and unmatched detection frame according to the principle of minimum Euclidean distance to achieve the third matching, which can reduce the tracking error caused by matching failure; we add the third matching after feature matching and detection frame matching, and match the unmatched trajectory according to the Euclidean distance between the center point of the last matched target frame and the center point of the current unmatched target detection frame. The calculation formula of the distance D is as follows:
[0061]
[0062] Where (x i ,y i ) is the center point position of the target box of the i-th Unmatched track when it was successfully matched last time
[0063] (x j ,y j ) is the center point position of the jth Unmatched detections
[0064] After the third-level matching is completed, the matching results are output, and we classify and analyze the results to determine whether we are off-duty or sleeping on the job.
[0065] Step C. judge the matching results based on the on-duty personnel objects tracked by the historical frames and the current frames. If the number of consecutive frames of the on-duty personnel exceeds the set threshold for judging sleeping on duty, the on-duty personnel is judged to be sleeping on duty. If the number of consecutive frames of the number of on-duty personnel is less than the set number of on-duty personnel at that time, the on-duty personnel is judged to be missing ID and off-duty.
[0066] After the third-level matching is completed, we get the output results and analyze them. For the successfully matched trajectories, if the category detection results of the same target within the set threshold frame number of 50 frames are all "sleep", then the ID on-duty personnel is judged to be sleeping on duty. If the number of successfully matched trajectories within the set threshold frame number of 50 frames is all less than the current number of on-duty personnel, then the missing ID personnel is judged to be off duty; for the trajectory that is not matched to the target frame, when it exceeds the set maximum number of unmatched frames max_age and is not associated, it will be deleted, which we initially set to 30 frames; for the target frame that is not matched successfully, it will be judged as a new trajectory, and the feature extractor will be used to extract the new target features and match them with the features in the feature library of off-duty personnel to determine whether the off-duty personnel have returned to work, keep the ID from being confused, and add it as a new trajectory to the Kalman filter for further re-judgment.
[0067] In the three-level matching process, for the personnel who are judged to be off-duty, before deleting their tracks, their first 50 frames of appearance features are saved separately to form an off-duty feature library. We save the features of the off-duty personnel according to ID classification to form an off-duty feature library. When a new target appears, it is mainly manifested as an unmatched target frame. The OSnet network is used to extract features, and the last 50 frames of images of the off-duty personnel saved before are fused and then matched with the new target features. The cosine distance between the features is calculated to judge. If it is judged to be a returning employee, it will be deleted from the unmatched target frame and added to the tracking track as a new track, keeping the ID information the same as before leaving the job, realizing the REID function. In addition, the number of personnel in the duty room is synchronized and fixed according to the number of people punching in. When the number of existing tracks is equal to the total number of people punching in the duty room on that day, the last target frame that is not matched with the track will be deleted, and no new tracks will be added.
[0068] For output personnel ID information, each ID information corresponds to the employee's name and other identity information. Employees need to punch in when they enter the duty room for the first time every day. By punching in, they are assigned an ID and their identity information is recorded. For the ID tracking process, we will control the ID update and judge the departure based on the total ID of the number of people punching in every day. The current number of people punching in is the number of people who should be on duty. If the number of people on duty is less than the current number of people within the set threshold frame number of 50 frames, it is judged that the missing ID person is off duty. For new targets, if the current number of people is the total number of people on duty, they are judged as strangers and will not be tracked.
[0069] Finally, the improved YOLOv5 target detection and multi-target tracking algorithms were integrated to build a sleeping post and leaving post detection system. First, the sleeping post dataset was divided into training set, validation set and test set according to a certain ratio for model training, tuning and testing. When evaluating the performance of the detection algorithm, we selected multiple performance indicators, including average precision, accuracy, recall rate and F1 value, to comprehensively evaluate the effect of the algorithm. In addition, we also conducted comparative experiments with other sleeping post detection algorithms, including traditional feature extraction-based methods and deep learning-based methods, to ensure fair comparison. Through the analysis of experimental results, we evaluated the detection accuracy and efficiency of the method under different sleeping post states, as well as its applicability and generalization ability on different datasets, providing a comprehensive and effective solution for the sleeping post detection task.
[0070] The embodiments of the present invention have been described in detail above in conjunction with the accompanying drawings, however, the present invention is not limited to the above embodiments. Within the knowledge of ordinary technicians, various changes and modifications can be made without departing from the purpose of the present invention. These changes and modifications may 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 on-duty personnel sleeping or leaving their posts based on identity confirmation, characterized in that The following steps are involved: Step A. Based on the improved YOLOv5 target detection model, the model is trained using images of duty room personnel sleeping and normal working images. The trained model is then used to monitor the work of duty room personnel in real time, and the detection frame of the duty personnel is output. The detection results of the sleeping and non-sleeping personnel are determined, and then step B is entered; Step B. Track the on-duty personnel detected by the target detection model, use the improved Strongsort multi-target tracking algorithm to track the IDs of the on-duty personnel in the two currently detected states, and record the ID information and sleeping post labels, and then proceed to step C; Step C. judge the matching results based on the on-duty personnel objects tracked by the historical frames and the current frames. If the number of consecutive frames of the on-duty personnel exceeds the set threshold for judging sleeping on duty, the on-duty personnel is judged to be sleeping on duty. If the number of consecutive frames of the number of on-duty personnel is less than the set number of on-duty personnel at that time, the on-duty personnel is judged to be missing ID and off-duty.
2. The method according to claim 1, characterized in that Here are the steps: Step A. Based on the YOLOv5 target detection model, the model is trained using images of duty room personnel sleeping and normal working images. The trained model is then used to monitor the work of duty room personnel in real time, and the detection frame of the duty personnel is output. The detection results of sleeping and non-sleeping are determined, and then step B is entered; For the detection of sleeping and leaving duty of duty room personnel, the camera is used to collect images of duty room personnel in different postures as a dataset, and each frame of images with sleeping and non-sleeping postures is marked to form a dataset. The targets in the dataset are labeled as "sleep" and "nosleep" respectively. When labeling, the number of datasets of the two categories is kept equal. At the same time, the dataset and validation set are divided, and the YOLOv5 network structure is trained to obtain the target detection model for sleeping personnel. The CIOU loss function of YOLOv5 is changed to MPDloU loss function: L MPDIoU =1-MPDIoU That The upper left and lower right coordinates of the local image prediction box of the target person in the sleeping state and the working state in the sample image, are the upper left and lower right coordinates of the real boxes of the target persons in the sleeping and working states in the sample image, and is the squared Euclidean distance between the predicted box and the true box, h and w are the height and width of the sample image, and I IOU is the intersection-over-union ratio of the predicted box and the detected box, MPDIoU is the intersection-over-union ratio of the distance between the predicted box and the detected box, L MPDIoU It is the distance intersection loss between the prediction box and the detection box; The last layer of the backbone in the YOLOv5 model adds an attention-connected improved SA module to form an improved YOLOv5 model structure combined with the SA attention mechanism, as follows: 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 ],X k ∈R C|G×H×W , during the training process, each sub-feature X k Gradually obtain a semantic response, and then use the 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 divided into two branches along the channel dimension X k1 ,X k2 ∈R C / 2G×H×W , processes the input data through two branches; the first branch X k1 Focus on the relationship between channels and generate channel attention maps to emphasize important channel information; the second branch X k2 Focus on the spatial relationship of features and generate a spatial attention map to highlight important spatial information; the outputs of these two branches are concatenated together to ensure that the number of channels matches the number of channels of the input data; finally, all features are aggregated along the channel dimension; X′ k1 =σ(W1d+b1)·X k1 X′ k2 =σ(W2·GN(X k2 )+b2)·X k2 Channel attention X′ k1 and spatial attention X′ k2 The output representations are shown in the above formula, where W1∈R C / 2G×1×1 and b1∈R C / 2G×1×1 Parameters for scaling and translating channel statistics s, GN is Group Norm, used to obtain spatial statistics, and W2, b2 are shapes of R C / 2G×1×1 Parameters, σ is the Sigmoid activation function; After completing the first two attention calculations, we need to integrate them, X k =[X′ K1 ,X′ K2 ]∈R C / G×H×W ,Finally, the channel permutation operation is used to share information between different ,groups so that the final output of SA is consistent with the input size; The default G of SA is 64. The specific process of improving the SA algorithm with G as 32 is as follows: 1) Input feature map X and divide it into 32 groups along the channel dimension, that is, X = [X1,…,X 32 ], and each group of X gradually captures a specific semantic response during the training process; 2) Divide each group X into two parts, one using channel attention and the other using spatial attention; 3) Superimpose the two parts according to the number of channels to achieve information fusion within the group; 4) Perform random mixing operations on all X to enable information flow between different groups; 5) Output feature map; Step B. Track the on-duty personnel detected by the target detection model, use the improved Strongsort multi-target tracking algorithm to track the IDs of the on-duty personnel in the two currently detected states, and record the ID information and sleeping post labels, and then proceed to step C; Match the predicted trajectory and the detected target through three-level matching; 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, replaces it with the OSnet network to extract features, and uses the feature update strategy to update the appearance state of the i-th trajectory at frame t in an exponential moving average (EMA) manner As shown below: in, is the appearance embedding of the current OSnet network detection, a is the momentum term, which is set to 0.9; For the motion feature part, ECC is used for camera motion compensation, and the NSA Kalman algorithm is used at the same time. It consists of a state estimation step and a state update step. First, an estimate of the current state variables and their uncertainty are generated, and then these estimates are updated with the weighted average of the estimated state and the measured value. The state vector here is an 8-dimensional vector Where (x, y) represents the coordinates of the center point of the trajectory rectangle, a is the aspect ratio of the box, and h is the height of the box. Represents the speed of (x, y, a, h) in the image coordinate system; The NSA Kalman algorithm proposes an adaptive calculation of the noise covariance The formula: Where R k is the preset constant measurement noise covariance, which is obtained by scaling the measured state vector and is set to (0.5*h, 0.5*h, 0.1, 0.5*h); c k is the detection confidence score in state k; In the matching process, the appearance feature distance is no longer used alone, but the appearance and motion information are considered at the same time. The cost matrix C is the appearance cost A a and the movement cost A m The weighted sum of is as follows: C=λA a +(1-λ)A m The weight factor λ is set to 0.98; After the first level of matching is completed, the successfully matched trajectory, unmatched trajectory, and unmatched detection box are output. When the feature matching cannot successfully match the predicted box, the algorithm will automatically perform IoU matching with the original detection box to determine their final matching status; DIoU (Distance Intersection over Union) is used to replace IoU; DIoU considers two indicators, IoU and center point distance, and its definition formula and loss function formula are as follows: L DIOU =1-I DIOU Where: I IOU is the intersection-over-union ratio of the predicted box and the detection, I DIOU is the intersection-over-union ratio of the distance between the prediction box and the detection box; ρ 2 (b,b gt ) is the Euclidean distance between the center point of the detection box and the prediction box, c is the diagonal length of the minimum circumscribed rectangle of the prediction box and the detection box; L DIOU It is the distance intersection loss between the prediction box and the detection box; After the second-level matching is completed, the successfully matched trajectory, unmatched trajectory, and unmatched detection frame are still output. The unmatched trajectory and unmatched detection frame are matched according to the principle of minimum Euclidean distance. The third matching is added after feature matching and detection frame matching. The unmatched trajectory is matched according to the Euclidean distance between the center point of the last successfully matched target frame and the center point of the current unmatched target detection frame. The calculation formula of the distance D is as follows: Where (x i ,y i ) is the center point position of the target box of the i-th Unmatched track when it was successfully matched last time (x j ,y j ) is the center point position of the jth Unmatched detections After the third-level matching is completed, the matching results are output and the results are classified and analyzed to determine whether the person is off duty or sleeping on duty; Step C. judge the matching result, based on the on-duty personnel objects tracked by the historical frames and the current frame, if the continuous frames of the on-duty personnel being on duty exceed the set judgment threshold of being on duty, then the on-duty personnel are judged to be on duty; if the continuous frames of the number of on-duty personnel being on duty are less than the set number of on-duty personnel at that time, then the on-duty personnel are judged to be missing ID and off-duty; After the three-level matching is completed, the output results are obtained and analyzed. For the successfully matched trajectories, if the category detection results of the same target within the set threshold frame number of 50 frames are all "sleep", then the ID on-duty personnel are judged to be sleeping on duty. If the number of successfully matched trajectories within the set threshold frame number of 50 frames is all less than the current number of on-duty personnel, then the missing ID personnel are judged to be off duty; for the trajectories that are not matched to the target frame, when they exceed the set maximum number of unmatched frames max_age and are not associated, they will be deleted, which is initially set to 30 frames; for the target frame that is not matched successfully, it is judged as a new trajectory, and the feature extractor is used to extract the new target features and the features in the feature library of off-duty personnel to match them, to determine whether the off-duty personnel have returned to work, to keep the ID from being confused, and to add it as a new trajectory to the Kalman filter for further re-judgment; In the three-level matching process, for the personnel who are judged to be off-duty, before deleting their trajectories, their first 50 frames of appearance features are saved separately to form an off-duty feature library; the features of the off-duty personnel are saved according to ID classification to form an off-duty feature library. When a new target appears, it is mainly manifested as an unmatched target frame. The OSnet network is used to extract its features, and the last 50 frames of images of the off-duty personnel saved previously are fused and then matched with the new target features. The cosine distance between the features is calculated to make a judgment. If it is judged to be a returning employee, it will be deleted from the unmatched target frame and added to the tracking trajectory as a new trajectory, keeping the ID information the same as before leaving the job; in addition, the number of personnel in the duty room is synchronized and fixed according to the number of people punching in. When the number of existing trajectories is equal to the total number of people punching in the duty room on that day, the last target frame that is not matched with the trajectory will be deleted, and no new trajectory will be added; For the output personnel ID information, each ID information corresponds to the employee's name and other identity information. Employees need to punch in when they enter the duty room for the first time every day. By punching in, they are assigned an ID and their identity information is recorded. For the ID tracking process, the total ID of the number of people punching in every day will be used to control ID updates and determine whether they are off duty. The current number of people punching in is the number of people who should be on duty. If the number of people on duty is less than the current number of people on duty within the set threshold frame number of 50 frames, it is judged that the person with missing ID is off duty. When a new target appears, if the current number of people is the total number of people on duty, it is judged as a stranger and will not be tracked.
Citation Information
Cited By
Multi-target floating garbage tracking method based on D-StrongSORT
CN119090919A
Robust aerocar air-ground target matching method and system
CN119762538A
