Surveillance video pedestrian trajectory tracking method and device based on re-identification
Through the surveillance video pedestrian trajectory tracking method based on re-identification, the pedestrian trajectory tracking model and clustering technology are used to solve the problems of low computational efficiency and poor accuracy of pedestrian trajectory tracking in the existing technology, achieving efficient and accurate trajectory tracking, and reducing labor and storage costs.
Patent Information
- Application Number
- CN202410493579.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-23
- Publication Date
- 2024-08-23
AI Technical Summary
Pedestrian trajectory tracking methods in the existing technology have low calculation efficiency, poor accuracy, high human resource consumption, high storage costs, and poor generalization when processing large-scale monitoring data.
The surveillance video pedestrian trajectory tracking method based on re-identification is used to obtain surveillance video data, extract pedestrian detection data, input the pedestrian re-identification model to obtain image feature vectors, perform density and hierarchical clustering, and project to a two-dimensional plane to achieve trajectory tracking .
It realizes fully automatic pedestrian trajectory tracking, saves labor, reduces storage costs, improves the accuracy and reliability of trajectory tracking, and meets actual use needs.
Smart Images

Figure CN118537787A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision technology, and in particular to a method and device for tracking pedestrian trajectories in surveillance videos based on re-identification. Background Art
[0002] With the rapid development of artificial intelligence, computer vision and other fields, pedestrian trajectory tracking is also moving towards automation and intelligence; among them, accurate pedestrian trajectory tracking is an important guarantee for security.
[0003] In the related technology, trajectory tracking can be performed based on manpower, or a single-camera trajectory tracking method based on machine learning can be used. A method for determining the target trajectory based on calculating the IoU (Intersection over Union) between adjacent frames can also be used. At the same time, a Kalman filter can be used for trajectory prediction to improve the accuracy of the solution.
[0004] However, the manual trajectory tracking method in the related technology is slow and inefficient, has difficulty in processing large-scale data, and has a high error rate and a large workload. The single-camera trajectory tracking method has problems with long-term monitoring data. The method of determining the target trajectory based on calculating the IoU between adjacent frames has a strong relationship between the coherence of the frames and the accuracy. When facing large-scale data such as monitoring data, it needs to be calculated frame by frame, which takes a long time to calculate and occupies a large amount of storage. Therefore, it is not easy to promote in the fields of monitoring data and cannot meet the actual use needs. Summary of the invention
[0005] The present application provides a surveillance video pedestrian trajectory tracking method, device and electronic device based on re-identification to solve the problems of low computational efficiency and poor accuracy of calculation results in pedestrian trajectory tracking in related technologies, as well as large human resource consumption and high solution storage cost, resulting in poor scalability.
[0006] The first aspect of the present application provides a surveillance video pedestrian trajectory tracking method based on re-identification, comprising the following steps: obtaining current surveillance video data; extracting pedestrian detection data from the current surveillance video data; inputting the pedestrian detection data into a pedestrian re-identification model, and the pedestrian re-identification model extracting the image feature vector of each pedestrian in the pedestrian detection data; normalizing and expanding the corresponding frame number of each pedestrian in the current surveillance video data, and then inserting the image feature vector of each pedestrian, and density clustering the image feature vector of each pedestrian to obtain a trajectory segment set; hierarchically clustering the trajectory segment set to obtain a trajectory clustering result, projecting the trajectory clustering result onto a two-dimensional plane map to obtain the true trajectory of each pedestrian, and realizing pedestrian trajectory tracking based on the true trajectory of each pedestrian.
[0007] Optionally, before inputting the pedestrian detection data into the pedestrian re-identification model, it also includes: obtaining historical surveillance video data; dividing the historical surveillance video data into a training set and a validation set, and performing data enhancement on the images in the training set, wherein the training set carries real labels; iteratively training the pedestrian re-identification model based on the training data set, during the iterative training process, calculating the training loss value based on the output value of the pedestrian re-identification model and the smoothed real label, and optimizing the weight of the pedestrian re-identification model by back propagation of the loss value; using the validation set to verify the trained pedestrian re-identification model until the training loss value is lower than the loss threshold or the iterative training of the pedestrian re-identification model reaches the target number of iterations, and stopping the iterative training.
[0008] Optionally, the corresponding frame number of each pedestrian in the current monitoring video data is normalized and expanded and then inserted into the image feature vector of each pedestrian, including: obtaining the total number of video frames of the current monitoring video data; generating a timing feature vector based on the corresponding frame number of each pedestrian in the current monitoring video data and the total number of video frames, and expanding the timing feature by a target multiple; and splicing the expanded timing feature vector to the image feature vector of each pedestrian.
[0009] Optionally, density clustering is performed on the image feature vector of each pedestrian to obtain the trajectory segment set, including: calculating the Euclidean distance between the image feature vectors of each pedestrian; and density clustering is performed on the image feature vector of each pedestrian based on the Euclidean distance to obtain the trajectory segment set.
[0010] Optionally, performing hierarchical clustering on the trajectory segment set to obtain the trajectory clustering result further includes: calculating the cosine distance of the trajectory segments in the trajectory segment set; and performing hierarchical clustering on the trajectory segment set based on the cosine distance to obtain the trajectory clustering result.
[0011] Optionally, the threshold of the hierarchical clustering is:
[0012]
[0013] Among them, threshold new is the newly selected clustering threshold, threshold old is the clustering threshold selected in the previous round, N h is the number of trajectory segments obtained after hierarchical clustering, and N is the number of trajectories without hierarchical clustering.
[0014] Optionally, extracting pedestrian detection data from current surveillance video data includes: inputting the current surveillance video data into a target detection model, and the target detection model extracting pedestrian detection data from the current surveillance video data.
[0015] Optionally, before the current monitoring video data is input into the target detection model, the method further includes: performing at least one preprocessing of image scaling, image horizontal flipping, image histogram equalization and random occlusion on the current monitoring video data.
[0016] The second aspect of the present application provides a surveillance video pedestrian trajectory tracking device based on re-identification, including: an acquisition module, used to acquire current surveillance video data; an extraction module, used to extract pedestrian detection data in the current surveillance video data; an input module, used to input the pedestrian detection data into a pedestrian re-identification model, and the pedestrian re-identification model extracts the image feature vector of each pedestrian in the pedestrian detection data; a clustering module, used to normalize and expand the corresponding frame number of each pedestrian in the current surveillance video data, and then insert the image feature vector of each pedestrian, and density cluster the image feature vector of each pedestrian to obtain a trajectory segment set; a tracking module, used to hierarchically cluster the trajectory segment set to obtain a trajectory clustering result, project the trajectory clustering result to a two-dimensional plane map to obtain the real trajectory of each pedestrian, and realize pedestrian trajectory tracking based on the real trajectory of each pedestrian.
[0017] Optionally, the surveillance video pedestrian trajectory tracking device based on re-identification is further used to: obtain historical surveillance video data before inputting pedestrian detection data into a pedestrian re-identification model; divide the historical surveillance video data into a training set and a verification set, and perform data enhancement on the images in the training set, wherein the training set carries real labels; iteratively train the pedestrian re-identification model based on the training data set, and during the iterative training process, calculate the training loss value based on the output value of the pedestrian re-identification model and the real label, and optimize the weight of the pedestrian re-identification model by back propagation of the loss value; use the verification set to verify the trained pedestrian re-identification model, and stop the iterative training until the training loss value is lower than the loss threshold or the iterative training of the pedestrian re-identification model reaches the target number of iterations.
[0018] Optionally, the clustering module is further used to: obtain the total number of video frames of the current monitoring video data; generate a time series feature vector based on the corresponding frame number of each pedestrian in the current monitoring video data and the total number of video frames, and expand the time series feature by a target multiple; and splice the expanded time series feature vector to the image feature vector of each pedestrian.
[0019] Optionally, the clustering module is further used to: calculate the Euclidean distance between the image feature vectors of each pedestrian; and perform density clustering on the image feature vectors of each pedestrian based on the Euclidean distance to obtain a set of trajectory segments.
[0020] Optionally, the tracking module is further used to: calculate the cosine distance of the trajectory segments in the trajectory segment set; and perform hierarchical clustering on the trajectory segment set based on the cosine distance to obtain a trajectory clustering result.
[0021] Optionally, the threshold for hierarchical clustering is:
[0022]
[0023] Among them, threshold new is the newly selected clustering threshold, threshold old is the clustering threshold selected in the previous round, N h is the number of trajectory segments obtained after hierarchical clustering, and N is the number of trajectories without hierarchical clustering.
[0024] Optionally, the extraction module is further used to: input the current monitoring video data into the target detection model, and the target detection model extracts pedestrian detection data from the current monitoring video data.
[0025] Optionally, the surveillance video pedestrian trajectory tracking device based on re-identification is further used to: perform at least one preprocessing of image scaling, image horizontal flipping, image histogram equalization and random occlusion on the current surveillance video data before inputting the current surveillance video data into the target detection model.
[0026] The third aspect of the present application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a surveillance video pedestrian trajectory tracking method based on re-identification as described in the above embodiment.
[0027] Therefore, this application has at least the following beneficial effects:
[0028] The embodiment of the present application can extract pedestrian detection data from surveillance video data, input the pedestrian detection data into a re-identification model to obtain a feature vector, and then obtain a trajectory clustering result by clustering, and project it to the ground to obtain the individual's real trajectory to achieve trajectory tracking; thus, the embodiment of the present application can fully automatically track the trajectory of pedestrians in surveillance videos, saving labor and reducing work burden; the trajectory clustering result of pedestrians can be obtained by only inputting videos, with low storage costs, convenient solutions, and strong generalizability; reliable tracking results can be obtained through multiple clustering, which improves the accuracy and reliability of pedestrian trajectory tracking; at the same time, since the embodiment of the present application uses pedestrian re-identification technology, and the underlying algorithms such as cosine distance calculation are implemented using matrix operations, a very high video frame rate is not required, and it is possible to improve recognition efficiency while reducing computing costs to meet actual usage needs.
[0029] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0031] Figure 1 A flowchart of a surveillance video pedestrian trajectory tracking method based on re-identification according to an embodiment of the present application;
[0032] Figure 2 A schematic diagram of the overall network structure for target detection and feature extraction according to an embodiment of the present application;
[0033] Figure 3 A schematic diagram of the online and offline parts of an embodiment of the present application;
[0034] Figure 4 This is an example diagram of a method for tracking pedestrian trajectories according to an embodiment of the present application;
[0035] Figure 5 This is an example diagram of a surveillance video pedestrian trajectory tracking device based on re-identification according to an embodiment of the present application;
[0036] Figure 6 A schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0037] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0038] In response to the problems mentioned in the above background technology, the present application provides a surveillance video pedestrian trajectory tracking method, device and electronic device based on re-identification, which are described in detail with reference to the accompanying drawings below.
[0039] Specifically, Figure 1 A flowchart of a method for tracking pedestrian trajectories in surveillance videos based on re-identification is provided in an embodiment of the present application.
[0040] like Figure 1 As shown, the surveillance video pedestrian trajectory tracking method based on re-identification includes the following steps:
[0041] In step S101, current surveillance video data is obtained.
[0042] It can be understood that the embodiments of the present application can acquire the surveillance video data of the current monitoring, wherein the embodiments of the present application can use at least one method to acquire the surveillance video data, and there is no specific limitation on this; the embodiments of the present application can also process the image frames after collecting the surveillance video data, wherein the processing of the image frames allows one frame to be sampled every specified frame, for example, one frame can be selected for sampling every five frames, etc., and there is no specific limitation on this; in the following embodiments, the elaboration is based on selecting one frame for sampling every five frames; thereby, the embodiments of the present application can reduce the calculation time and thus save computing resources.
[0043] In step S102, pedestrian detection data in the current monitoring video data is extracted.
[0044] It can be understood that the embodiments of the present application can extract pedestrian detection data from the acquired surveillance video data, wherein the embodiments of the present application can use at least one method to extract pedestrian detection data. In the following embodiments, the embodiments of the present application use a target detection model to extract pedestrian detection data, as follows:
[0045] In an embodiment of the present application, extracting pedestrian detection data from current surveillance video data includes: inputting the current surveillance video data into a target detection model, and the target detection model extracting pedestrian detection data from the current surveillance video data.
[0046] It can be understood that the embodiment of the present application can input the current monitoring video data into the target model and rely on the target model to detect and extract the data; among them, the target detection model of the embodiment of the present application can be selected according to the actual situation. In the following embodiments, the target detection model will be explained based on the two-stage target detection model YOLO (You Only Look Once).
[0047] Specifically, the network structure of the target detection model in the embodiment of the present application can be as follows: Figure 2 As shown in the figure, its backbone network uses CSPDarknet53, which has high feature extraction capability and computational efficiency. When the image enters the backbone network and is converted into a feature map, the feature map enters the Neck network. The Neck network uses the SPP (Spatial Pyramid Pooling) module for pooling to capture feature maps of different sizes, and realizes feature fusion of different scales through the PANet (Path Aggregation network) with FPN (Feature Pyramid Networks) structure.
[0048] In an embodiment of the present application, before the current monitoring video data is input into the target detection model, it also includes: performing at least one preprocessing of image scaling, image horizontal flipping, image histogram equalization and random occlusion on the current monitoring video data.
[0049] It can be understood that the embodiment of the present application can perform at least one pre-processing on the image and then input the processed image data into the target detection model, thereby performing data enhancement on the image through at least one method such as image scaling, image horizontal flipping, image histogram equalization and random occlusion; thus, the embodiment of the present application can enhance the output robustness of the network to the input data and meet actual needs.
[0050] For example, the embodiments of the present application can scale the input image to a set size with an equal aspect ratio and perform padding; flip the image horizontally with a probability of 0.5; perform histogram equalization on the V component of the image HSV (Hue, Saturation, Value, HSV color space) space; and randomly occlude the image.
[0051] In the embodiment of the present application, after feature extraction is performed on the feature map, generally three feature maps of different scales representing prediction boxes of different scales are included. The model predicts the bounding box position and size of the target by using the anchor box in the output layer, and uses the Softmax function to calculate the probability of being a pedestrian, and finds the target with the largest IoU with the true value as its corresponding matching target, and uses DIoU (Distance-IoU) as the loss function, which is expressed as follows:
[0052]
[0053] Among them, ρ 2 (b,b gt ) represents the square of the Euclidean distance between the center of the detection box and the real box, c 2 Indicates the diagonal length of the smallest rectangle covering the detection box and the ground-truth box.
[0054] In step S103, the pedestrian detection data is input into a pedestrian re-identification model, and the pedestrian re-identification model extracts an image feature vector of each pedestrian in the pedestrian detection data.
[0055] It can be understood that the embodiment of the present application can input the extracted pedestrian detection data into the pedestrian re-identification model to further extract the image feature vector of each person in the pedestrian detection data; wherein, before inputting the pedestrian detection data into the pedestrian re-identification model, the embodiment of the present application can also obtain the pedestrian re-identification model, and the pedestrian re-identification model can be obtained using at least one method, specifically as follows:
[0056] In an embodiment of the present application, before inputting pedestrian detection data into a pedestrian re-identification model, it also includes: obtaining historical surveillance video data; dividing the historical surveillance video data into a training set and a validation set, and performing data enhancement on the images in the training set and the validation set, wherein the training set carries real labels; iteratively training the pedestrian re-identification model based on the training data set, during the iterative training process, calculating the training loss value based on the output value of the pedestrian re-identification model and the real label, and optimizing the weight of the pedestrian re-identification model by back propagation of the loss value; using the validation set to verify the trained pedestrian re-identification model, and stopping the iterative training until the training loss value is lower than the loss threshold or the iterative training of the pedestrian re-identification model reaches the target number of iterations.
[0057] Among them, the loss threshold and the target number of iterations can be set according to actual conditions and are not specifically limited.
[0058] It can be understood that the embodiments of the present application can divide the training set and the validation set into batches of equal size, and calculate the loss of the output value and the label through forward propagation, and optimize the pedestrian re-identification model weights through loss back propagation until the loss is lower than the loss threshold or the maximum number of training times is reached, and the final pedestrian re-identification model can be obtained; thus, the embodiments of the present application can obtain reliable data results through iterative training and improve the accuracy of the solution.
[0059] Specifically, the embodiment of the present application can be performed using a model based on ReID Strong Baseline, and the backbone network of the model is ResNet50; at the same time, the embodiment of the present application also uses the ResNet50 parameters pre-trained on ImageNet as the model, and changes the number of fully connected layers of the output to the number of identities in the training set; the following embodiments will be described based on the above model:
[0060] (1) Dataset Division
[0061] In the embodiment of the present application, after acquiring the historical surveillance video data, the historical surveillance video data can be divided into a training set and a verification set.
[0062] (2) Data enhancement
[0063] The embodiment of the present application can perform data enhancement on the input image, and the specific operations are: scaling the input image to a set size with an equal aspect ratio and padding it; horizontally flipping the image with a specific probability, such as horizontally flipping with a probability of 0.5; performing histogram equalization on the V component of the HSV space of the image; and randomly occluding the image.
[0064] (3) Model training
[0065] The model training of the embodiment of the present application can read several images of the same person, extract features using ResNet50 and pass through the GAP (Global Average Pooling) layer to obtain the preliminary features f t , use the preliminary features to pass through the BN (Batch Normalization) layer to obtain the features f used in the inference stage i , and is mapped to labels after passing through the fully connected layer.
[0066] (4) Calculation of loss value
[0067] During model training in the embodiment of the present application, a weighted sum of center loss, ternary loss and label loss is used as the loss function, wherein the label loss is loss smoothed.
[0068] The losses in the embodiments of the present application are defined as follows:
[0069] Center loss:
[0070] Ternary loss: L Tri =[d p -d n +α] + ,
[0071] ID Loss:
[0072] ID Smoothing:
[0073] in, It is the yth j The cluster center of the class, d p ,d n are the distances between the input target and the positive and negative sample pairs, α is the set threshold; ID loss uses cross entropy loss, p i Represents the predicted value for the i-th image; ε is a small constant in ID smoothing to prevent overfitting.
[0074] In the embodiment of the present application, assuming that β is a small constant, the final loss function is:
[0075] L=βL C +L ID +L Tri ,
[0076] In the following embodiments, β is 0.001, α is 0.3, and ε is 0.1.
[0077] (5) Iterative training
[0078] The embodiment of the present application can repeat the above steps until the loss is lower than the threshold or the maximum number of training times is reached. For example, the iterative training of the embodiment of the present application can adopt a learning rate decay strategy, reducing the learning rate by half every 10 training rounds, iterating 50 training rounds in total, and setting the initial learning rate to 0.0005; thus, when it is judged that the loss value obtained by training is lower than the loss threshold or the number of iterations reaches the target number of iterations, the iterative training is stopped to obtain the final pedestrian re-identification model.
[0079] In step S104, the corresponding frame number of each pedestrian in the current monitoring video data is normalized and expanded, and then inserted into the image feature vector of each pedestrian, and density clustering is performed on the image feature vector of each pedestrian to obtain a set of trajectory segments.
[0080] It can be understood that the embodiment of the present application can input the pedestrian image slices obtained by the target detection model into the above-mentioned pedestrian re-identification model, thereby obtaining the image feature vector of each pedestrian corresponding to each image; further normalize and expand the corresponding frame number of the pedestrian, insert it into the image feature vector of each pedestrian, and perform density clustering on the above-mentioned image feature vector to obtain small trajectory segments, thereby obtaining a set of trajectory segments; wherein, the process of obtaining the trajectory segments in the embodiment of the present application can be specifically as follows:
[0081] (1) In an embodiment of the present application, the corresponding frame number of each pedestrian in the current monitoring video data is normalized and expanded and then inserted into the image feature vector of each pedestrian, including: obtaining the total number of video frames of the current monitoring video data; generating a time series feature vector based on the corresponding frame number of each pedestrian in the current monitoring video data and the total number of video frames, and expanding the time series feature by a target multiple; and splicing the expanded time series feature vector to the image feature vector of each pedestrian.
[0082] It can be understood that the present application can obtain the total number of frames of the current monitoring video data, and then generate a timing feature vector containing timing information based on the total number of frames and the corresponding number of frames for each pedestrian, wherein the timing feature can be obtained by dividing the number of frames of the video corresponding to the image by the total number of frames; the obtained timing feature vector is expanded, wherein the target multiple of the expansion can be set according to the actual situation, and there is no specific limitation on this. For example, after the expansion, a 2304-dimensional feature vector corresponding to each image can be obtained; after obtaining the expanded timing feature vector, the expanded timing feature vector is further spliced to the image feature vector of each pedestrian.
[0083] For example, in an embodiment of the present application, the time series features can be expanded 256 times and added to a 2048-dimensional image feature vector, and then fused into a 2304-dimensional feature vector.
[0084] (2) In an embodiment of the present application, density clustering is performed on the image feature vector of each pedestrian to obtain a set of trajectory segments, including: calculating the Euclidean distance between the image feature vectors of each pedestrian; and density clustering is performed on the image feature vector of each pedestrian based on the Euclidean distance to obtain a set of trajectory segments.
[0085] It is understandable that the embodiment of the present application can calculate the Euclidean distance between the image feature vectors of each pedestrian, and density cluster the image feature vectors of each pedestrian based on the calculated Euclidean distance, thereby preventing missed detection in some cases.
[0086] Specifically, the embodiment of the present application can use the DBSCAN (Density-Based Spatial Clustering of Applications with Noise) clustering algorithm for clustering, where ε and MinPts can be set according to the actual video frame rate and sampling interval, for example, ε can be 8.5, MinPts can be 3, etc., without specific limitation.
[0087] In the following embodiments, the description will be based on the assumption that ε is 8.5 and MinPts is 3; the clustering algorithm of the embodiment of the present application can be shown in Table 1 below:
[0088] Table 1
[0089]
[0090] In step S105, hierarchical clustering is performed on the trajectory segment set to obtain a trajectory clustering result, and the trajectory clustering result is projected onto a two-dimensional plane map to obtain the true trajectory of each pedestrian, and pedestrian trajectory tracking is achieved based on the true trajectory of each pedestrian.
[0091] It can be understood that the embodiments of the present application can perform hierarchical clustering on the trajectory segment set so that the number of clustered trajectories is reduced to a specified multiple of the original number as the final trajectory clustering result, and project the trajectory clustering result onto a two-dimensional plane map, thereby obtaining the true trajectory of each pedestrian, thereby realizing pedestrian trajectory tracking based on the pedestrian's true trajectory.
[0092] In an embodiment of the present application, performing hierarchical clustering on the trajectory segment set to obtain a trajectory clustering result further includes: calculating the cosine distance of the trajectory segments in the trajectory segment set; and performing hierarchical clustering on the trajectory segment set based on the cosine distance to obtain a trajectory clustering result.
[0093] It can be understood that the embodiment of the present application can calculate the cosine distance of the trajectory segments in the trajectory segment set, and hierarchically cluster the trajectory segments based on the cosine distance to obtain the final trajectory clustering result. Therefore, the embodiment of the present application can avoid the clustering of targets that stay for a long time in the camera field of view into multiple categories after the introduction of time series features; wherein, the cosine distance calculation formula of the embodiment of the present application can be:
[0094]
[0095] Among them, a is the minimum value of the number of new cluster categories and the number of original categories, and b is the maximum value of the number of new cluster categories and the number of original categories.
[0096] Next, the embodiment of the present application can perform hierarchical clustering of the specified multiple intervals based on the above cosine distance as shown in Table 2:
[0097] Table 2
[0098]
[0099] The threshold of hierarchical clustering in the embodiment of the present application is:
[0100]
[0101] Among them, threshold new is the newly selected clustering threshold, threshold old is the clustering threshold selected in the previous round, N h is the number of trajectory segments obtained after hierarchical clustering, N is the number of trajectories without hierarchical clustering, and the cluster distance measurement standard at this stage is cosine distance.
[0102] After obtaining the trajectory clustering results, the embodiment of the present application can project the clustering results onto a two-dimensional plane map, wherein the embodiment of the present application can use a transmission transformation method for projection, select four points in the monitoring perspective and the real two-dimensional map respectively and align them one by one, estimate the transmission transformation matrix through the relationship between the four points, and then use the midpoint below the pedestrian detection box as the trajectory point, and then estimate the pedestrian detection box of each category to output the real trajectory of the pedestrian.
[0103] Therefore, the embodiment of the present application can realize pedestrian trajectory tracking based on the obtained real trajectory of the pedestrian; wherein, the surveillance video pedestrian trajectory tracking method based on re-identification of the above steps S101 to S105 of the embodiment of the present application can be divided into two parts: offline and online. Figure 3 As shown, the details are as follows:
[0104] (1) Offline stage: Collect surveillance videos required for training, process them into frames, and construct Figure 2 A deep target detection neural network model is provided; after detecting and annotating pedestrian slices using the target detection network, the pedestrian slices are divided into training samples and verification samples, and the training samples and verification samples are preprocessed respectively; the neural network model is forward propagated using the training set, and the training error is back-propagated using a specified loss function, and after each round of iteration, the accuracy of the entire model in predicting target matching on the verification set is calculated until a preset training step is reached.
[0105] (2) Online stage: The acquired surveillance video is processed into frames, and pedestrian slice images are obtained through the target detection model. Then, the feature vector of each image is obtained through the pedestrian re-identification model, and the time series information is added; the DBSCAN clustering algorithm is used to obtain preliminary clustered small trajectory fragments, and the feature vector of each small trajectory fragment is calculated to obtain the average feature vector of the small trajectory fragment; the feature vectors of the small trajectory fragments are clustered into the final trajectory according to the hierarchical clustering algorithm with a specified multiple interval, and the result is projected onto a two-dimensional real map to obtain the result.
[0106] The following will describe the surveillance video pedestrian trajectory tracking method based on re-identification of the present application through a specific embodiment. Figure 4 As shown, the details are as follows:
[0107] Step S01: Collect the surveillance video to be tracked and process it into image frames;
[0108] Step S02: using the target detection model to extract pedestrians appearing in the video;
[0109] Step S03: Divide the training set and the validation set into batches of equal size, perform data enhancement on the images, and calculate the loss of the output value and the label through input forward propagation, and optimize the weight of the pedestrian re-identification model through loss back propagation;
[0110] Step S04: Repeat step S03 until the loss is lower than the threshold or the maximum number of training times is reached, and obtain the final pedestrian re-identification model;
[0111] Step S05: extracting features of each pedestrian detection image using a pedestrian re-identification model for the detection frame results obtained by the target detection model;
[0112] Step S06: normalize the number of frames corresponding to the pedestrian, expand it by a specified multiple, and insert it into the feature vector of each pedestrian image, and perform DBSCAN clustering to obtain small track segments;
[0113] Step S07: hierarchical clustering is performed on the small trajectory fragments, so that the number of trajectories after clustering is reduced to a specified multiple of the original, as the final trajectory result;
[0114] Step S08: Projecting the trajectory onto a two-dimensional plane map.
[0115] In summary, according to the surveillance video pedestrian trajectory tracking method based on re-identification proposed in the embodiment of the present application, pedestrian detection data in the surveillance video data can be extracted, the pedestrian detection data can be input into the re-identification model to obtain the feature vector, and then the trajectory clustering result can be obtained by clustering, and then projected to the ground to obtain the individual's real trajectory to achieve trajectory tracking.
[0116] Therefore, the embodiments of the present application have at least the following advantages:
[0117] (1) Accurate and robust pedestrian tracking can be achieved using only one surveillance camera and the surveillance data it obtains. The pedestrian trajectory in the surveillance video can be fully automatically tracked, effectively solving the problems of high labor resources, heavy workload, and low data authenticity caused by excessive human participation, saving labor and reducing workload.
[0118] (2) The network’s output robustness to input data can be enhanced by preprocessing the input image data. At the same time, reliable tracking results can be obtained through multiple clustering, which improves the accuracy and reliability of pedestrian trajectory tracking.
[0119] (3) The pedestrian trajectory clustering results can be obtained by inputting only the video, with low storage cost, convenient solution, strong scalability and wide adaptability;
[0120] (4) At the same time, since the embodiment of the present application uses pedestrian re-identification technology, and the underlying algorithms such as cosine distance calculation are implemented using matrix operations, a very high video frame rate is not required. It is possible to reduce the computing cost while improving the recognition efficiency, and further reduce the computing cost to meet actual use needs.
[0121] Next, a surveillance video pedestrian trajectory tracking device based on re-identification proposed in accordance with an embodiment of the present application is described with reference to the accompanying drawings.
[0122] Figure 5 It is a block diagram of a surveillance video pedestrian trajectory tracking device based on re-identification according to an embodiment of the present application.
[0123] like Figure 5 As shown, the surveillance video pedestrian trajectory tracking device 10 based on re-identification includes: an acquisition module 100, an extraction module 200, an input module 300, a clustering module 400 and a tracking module 500.
[0124] Among them, the acquisition module 100 is used to acquire the current monitoring video data; the extraction module 200 is used to extract the pedestrian detection data in the current monitoring video data; the input module 300 is used to input the pedestrian detection data into the pedestrian re-identification model, and the pedestrian re-identification model extracts the image feature vector of each pedestrian in the pedestrian detection data; the clustering module 400 is used to normalize and expand the corresponding frame number of each pedestrian in the current monitoring video data, and then insert the image feature vector of each pedestrian, and density cluster the image feature vector of each pedestrian to obtain a trajectory segment set; the tracking module 500 is used to hierarchically cluster the trajectory segment set to obtain a trajectory clustering result, project the trajectory clustering result to a two-dimensional plane map to obtain the real trajectory of each pedestrian, and realize pedestrian trajectory tracking based on the real trajectory of each pedestrian.
[0125] In an embodiment of the present application, the surveillance video pedestrian trajectory tracking device 10 based on re-identification is further used to: obtain historical surveillance video data before inputting pedestrian detection data into a pedestrian re-identification model; divide the historical surveillance video data into a training set and a verification set, and perform data enhancement on the images in the training set, wherein the training set carries real labels; iteratively train the pedestrian re-identification model based on the training data set, and during the iterative training process, calculate the training loss value based on the output value of the pedestrian re-identification model and the real label, and optimize the weight of the pedestrian re-identification model by back propagation of the loss value; use the verification set to verify the trained pedestrian re-identification model until the training loss value is lower than the loss threshold or the iterative training of the pedestrian re-identification model reaches the target number of iterations, and stop the iterative training.
[0126] In an embodiment of the present application, the clustering module 400 is further used to: obtain the total number of video frames of the current monitoring video data; generate a timing feature vector based on the corresponding frame number of each pedestrian in the current monitoring video data and the total number of video frames, and expand the timing feature by a specified multiple; and splice the expanded timing feature vector to the image feature vector of each pedestrian.
[0127] In the embodiment of the present application, the clustering module 400 is further used to: calculate the Euclidean distance between the image feature vectors of each pedestrian; and perform density clustering on the image feature vectors of each pedestrian based on the Euclidean distance to obtain a set of trajectory segments.
[0128] In the embodiment of the present application, the tracking module 500 is further used to: calculate the cosine distance of the trajectory segments in the trajectory segment set; and perform hierarchical clustering on the trajectory segment set based on the cosine distance to obtain a trajectory clustering result.
[0129] In the embodiment of the present application, the threshold of hierarchical clustering is:
[0130]
[0131] Among them, threshold new is the newly selected clustering threshold, threshold old is the clustering threshold selected in the previous round, N h is the number of trajectory segments obtained after hierarchical clustering, and N is the number of trajectories without hierarchical clustering.
[0132] In an embodiment of the present application, the extraction module 200 is further used to: input the current monitoring video data into the target detection model, and the target detection model extracts pedestrian detection data from the current monitoring video data.
[0133] In an embodiment of the present application, the surveillance video pedestrian trajectory tracking device 10 based on re-identification is further used to: perform at least one pre-processing of image scaling, image horizontal flipping, image histogram equalization and random occlusion on the current surveillance video data before inputting the current surveillance video data into the target detection model.
[0134] It should be noted that the aforementioned explanation of the embodiment of the surveillance video pedestrian trajectory tracking method based on re-identification is also applicable to the surveillance video pedestrian trajectory tracking device based on re-identification of this embodiment, and will not be repeated here.
[0135] According to the surveillance video pedestrian trajectory tracking device based on re-identification proposed in the embodiment of the present application, the trajectory of pedestrians in the surveillance video can be tracked automatically, saving labor and reducing the workload; the pedestrian trajectory clustering results can be obtained by inputting only the video, the storage cost is low, the solution is convenient, and the scalability is strong; reliable tracking results can be obtained through multiple clustering, which improves the accuracy and reliability of pedestrian trajectory tracking; at the same time, since the embodiment of the present application uses pedestrian re-identification technology, and the underlying algorithms such as cosine distance calculation are implemented using matrix operations, a very high video frame rate is not required, which can achieve the improvement of recognition efficiency while reducing computing costs to meet actual usage needs.
[0136] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include:
[0137] A memory 601 , a processor 602 , and a computer program stored in the memory 601 and executable on the processor 602 .
[0138] When the processor 602 executes the program, the surveillance video pedestrian trajectory tracking method based on re-identification provided in the above embodiment is implemented.
[0139] Furthermore, the electronic device further comprises:
[0140] The communication interface 603 is used for communication between the memory 601 and the processor 602 .
[0141] The memory 601 is used to store computer programs that can be executed on the processor 602 .
[0142] The memory 601 may include a high-speed RAM (Random Access Memory) memory, and may also include a non-volatile memory, such as at least one disk memory.
[0143] If the memory 601, the processor 602 and the communication interface 603 are implemented independently, the communication interface 603, the memory 601 and the processor 602 can be connected to each other through a bus and communicate with each other. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can 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.
[0144] Optionally, in a specific implementation, if the memory 601, the processor 602 and the communication interface 603 are integrated on a chip, the memory 601, the processor 602 and the communication interface 603 can communicate with each other through an internal interface.
[0145] The processor 602 may be a CPU (Central Processing Unit), or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application.
[0146] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms are not necessarily directed to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0147] In addition, the terms "first" and "second" 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. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0148] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0149] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array, a field programmable gate array, etc.
[0150] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0151] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A surveillance video pedestrian trajectory tracking method based on re-identification, It is characterized in that The following steps are involved: Get current surveillance video data; Extracting pedestrian detection data from the current surveillance video data; Inputting the pedestrian detection data into a pedestrian re-identification model, wherein the pedestrian re-identification model extracts an image feature vector of each pedestrian in the pedestrian detection data; Normalizing and expanding the corresponding frame number of each pedestrian in the current monitoring video data and inserting it into the image feature vector of each pedestrian, and performing density clustering on the image feature vector of each pedestrian to obtain a trajectory segment set; Hierarchical clustering is performed on the trajectory segment set to obtain a trajectory clustering result, the trajectory clustering result is projected onto a two-dimensional plane map to obtain a true trajectory of each pedestrian, and pedestrian trajectory tracking is achieved based on the true trajectory of each pedestrian.
2. The surveillance video pedestrian trajectory tracking method based on re-identification according to claim 1, It is characterized in that Before inputting the pedestrian detection data into the pedestrian re-identification model, the method further includes: Obtain historical surveillance video data; Dividing the historical surveillance video data into a training set and a validation set, and performing data enhancement on the images in the training set, wherein the training set carries a true label; Iteratively training the person re-identification model based on the training data set, calculating a training loss value based on an output value of the person re-identification model and the true label during the iterative training process, and optimizing a weight of the person re-identification model by back propagation of the loss value; The trained person re-identification model is verified using the verification set, and the iterative training is stopped when the training loss value is lower than a loss threshold or the iterative training of the person re-identification model reaches a target number of iterations.
3. The surveillance video pedestrian trajectory tracking method based on re-identification according to claim 1, It is characterized in that The normalizing and expanding the corresponding frame number of each pedestrian in the current monitoring video data and inserting it into the image feature vector of each pedestrian includes: Obtain the total number of video frames of the current monitoring video data; Generate a time series feature vector based on the corresponding frame number of each pedestrian in the current monitoring video data and the total frame number of the video, and expand the time series feature by a target multiple; The expanded time series feature vector is concatenated to the image feature vector of each pedestrian.
4. The method for tracking pedestrian trajectories in surveillance videos based on re-identification according to claim 1, It is characterized in that The step of performing density clustering on the image feature vector of each pedestrian to obtain a set of trajectory segments includes: Calculating the Euclidean distance between the image feature vectors of each pedestrian; Density clustering is performed on the image feature vector of each pedestrian based on the Euclidean distance to obtain a trajectory segment set.
5. The surveillance video pedestrian trajectory tracking method based on re-identification according to claim 1, It is characterized in that The step of performing hierarchical clustering on the trajectory segment set to obtain a trajectory clustering result further includes: Calculating the cosine distance of the trajectory segments in the trajectory segment set; Hierarchical clustering is performed on the trajectory segment set based on the cosine distance to obtain a trajectory clustering result.
6. The method for tracking pedestrian trajectories in surveillance video based on re-identification according to claim 5, It is characterized in that The threshold of the hierarchical clustering is: Among them, threshold new is the newly selected clustering threshold, threshold old is the clustering threshold selected in the previous round, N h is the number of trajectory segments obtained after hierarchical clustering, and N is the number of trajectories without hierarchical clustering.
7. The surveillance video pedestrian trajectory tracking method based on re-identification according to claim 1, It is characterized in that The extracting of pedestrian detection data from the current monitoring video data includes: The current monitoring video data is input into a target detection model, and the target detection model extracts pedestrian detection data from the current monitoring video data.
8. The method for tracking pedestrian trajectories in surveillance videos based on re-identification according to claim 7, It is characterized in that Before inputting the current monitoring video data into the target detection model, the method further includes: The current monitoring video data is preprocessed by at least one of image scaling, image horizontal flipping, image histogram equalization and random occlusion.
9. A surveillance video pedestrian trajectory tracking device based on re-identification, It is characterized in that The device includes: The acquisition module is used to obtain the current surveillance video data; An extraction module, used to extract pedestrian detection data from the current monitoring video data; An input module, used for inputting the pedestrian detection data into a pedestrian re-identification model, wherein the pedestrian re-identification model extracts an image feature vector of each pedestrian in the pedestrian detection data; A clustering module, used for normalizing and expanding the corresponding frame number of each pedestrian in the current monitoring video data and inserting it into the image feature vector of each pedestrian, and performing density clustering on the image feature vector of each pedestrian to obtain a set of trajectory segments; The tracking module is used to perform hierarchical clustering on the trajectory segment set to obtain a trajectory clustering result, project the trajectory clustering result onto a two-dimensional plane map to obtain a real trajectory of each pedestrian, and implement pedestrian trajectory tracking based on the real trajectory of each pedestrian.
10. An electronic device, It is characterized in that include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the surveillance video pedestrian trajectory tracking method based on re-identification as described in any one of claims 1 to 8.
Citation Information
Cited By
Multi-level clustering-based semi-supervised person re-identification method
WO2026183821A1
