A video pedestrian flow estimation method based on one-to-many matching strategy
By employing a one-to-many matching strategy, combined with convolutional neural networks and self-attention mechanisms, the problems of parameter sensitivity and occlusion effects in existing technologies are solved, achieving higher accuracy and robustness in pedestrian flow estimation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAZHONG UNIV OF SCI & TECH
- Filing Date
- 2025-06-03
- Publication Date
- 2026-05-19
AI Technical Summary
Among existing methods for estimating pedestrian traffic in videos, bipartite graph matching requires empirical thresholds, resulting in high parameter sensitivity, while implicit matching strategies rely on one-to-one matching, which is easily affected by occlusion, motion, and pose changes, leading to insufficient counting accuracy.
A one-to-many matching strategy is adopted. Pedestrian appearance and location features are extracted through a convolutional neural network. Feature similarity is calculated using a decoupled multi-head self-attention mechanism. The pedestrian matching probability is predicted by a discriminator, allowing pedestrians to match with other pedestrians in spatially adjacent locations, thus reducing the dependence on parameters.
It improves the accuracy and robustness of pedestrian flow counting, reduces the model's sensitivity to parameters, enables accurate counting in different scenarios, and provides intuitive visualization results.
Smart Images

Figure CN120635981B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of pedestrian flow detection technology, and in particular relates to a video pedestrian flow estimation method based on a one-to-many matching strategy. Background Technology
[0002] With the continuous development of counting technologies such as artificial intelligence and computer vision, video crowd counting (VCC) has been widely adopted to monitor crowd density based on video surveillance and computer vision technology in order to reduce the risks associated with crowding.
[0003] Current technologies for counting pedestrian traffic in videos use bipartite graphs or privacy matching, but these methods suffer from several drawbacks. Firstly, existing bipartite graph matching typically requires an empirical threshold to filter out incorrect matches, increasing the model's sensitivity to parameters. Secondly, while implicit matching eliminates the drawbacks of setting a threshold parameter, its core principle, especially in training strategies, still follows a one-to-one matching approach. This one-to-one matching heavily relies on discriminative individual feature representations, making it highly sensitive to appearance changes caused by occlusion, motion, and pose variations.
[0004] Therefore, a video pedestrian traffic estimation method using one-to-many matching with “group context” is proposed. Summary of the Invention
[0005] The purpose of this invention is to provide a video pedestrian flow estimation method based on a one-to-many matching strategy. By using one-to-many matching, it fully utilizes the group characteristics of small groups of people, thereby improving the accuracy of pedestrian flow counting. The technical solution is as follows:
[0006] A video pedestrian traffic estimation method based on a one-to-many matching strategy includes the following steps:
[0007] S1. Periodically sample the video to obtain video frames. To extract two consecutive frames from a video frame Perform pedestrian detection and localization to obtain the head coordinates of pedestrians;
[0008] S2. Based on the head positioning coordinates, from two consecutive frames of images Pedestrian image patch in the middle and Image patches extracted using convolutional neural networks The appearance features of pedestrians are analyzed, and positional features are obtained by encoding the position using head positioning coordinates. The appearance features and positional features are then concatenated to obtain the pedestrian features. and ;
[0009] S3. Pedestrian features from two consecutive frames. and spliced into a matrix Then, the matrix is calculated using a decoupled multi-head self-attention mechanism. The similarity between elements is used to obtain a self-attention map A. Pedestrian feature similarity is extracted from self-attention map A, and the mean of this similarity is concatenated with the semantically matched features obtained from self-attention map A to obtain semantically enhanced pedestrian features. ;
[0010] S4. Separating pedestrian features Pedestrian features were obtained from two frames of images. Calculate pedestrian features from two frames of images. The Hadamard product between the two is used to obtain a three-dimensional similarity matrix. The similarity matrix is then input into a discriminator to predict the pedestrian matching probability. The number of people flowing in or out is distinguished based on the matching probability, and the number of people flowing in from each frame is accumulated to obtain the total flow.
[0011] Furthermore, in step S1, a universal head locator (PET) is used to detect and locate pedestrians in the video frame image.
[0012] Furthermore, step S2 specifically includes the following steps:
[0013] S201. Using the pedestrian's head coordinates as a reference point, analyze two consecutive frames of images... The size of the pixel containing the pedestrian in the middle is 1. The rectangular region was obtained using bilinear interpolation. Pedestrian image patches of various sizes and ;
[0014] S202. Image patches are extracted using a convolutional neural network ConvNeXt-s. Pedestrian appearance features at a medium resolution of 1 / 32;
[0015] S203. Based on the coordinates of the pedestrian's head location point, sinusoidal position coding is used to obtain a position code with 256 channels. Inputting this into a one-dimensional convolutional layer with a kernel size of 1, a position code with 1152 channels is obtained, thus acquiring the position features.
[0016] S204. Combine the pedestrian's physical features with their location features to obtain the pedestrian features. and .
[0017] Furthermore, step S3 includes:
[0018] S301. Pedestrian features from two consecutive frames of images. and Concatenate into a four-dimensional pedestrian feature matrix The four-dimensional pedestrian feature matrix is transformed by matrix transformation. The feature matrix of pedestrians is obtained by flattening along the spatial dimension, and the number of channels is reduced to 256 by passing it through a two-dimensional convolutional layer with a kernel of 1, resulting in a 256-dimensional pedestrian feature matrix. As input to the self-attention layer;
[0019] S302. Utilize a decoupled 8-head self-attention mechanism to process the 256-dimensional pedestrian feature matrix. Implicit feature matching is performed; in the self-attention layer, the 256-dimensional pedestrian feature matrix is analyzed. Projecting the query Q, key K, and value V, we obtain the self-attention graph by calculating the similarity between query Q and key K using a self-attention mechanism. Multiplying it with the value V yields features with semantic matching. ;
[0020] S303, From Self-Attention Map Extract the pedestrian feature similarity component reflecting the two frames of images. Then, the pedestrian feature similarity part Calculate the average value along the spatial dimension , average With features By concatenating the features, we obtain pedestrian features with enhanced semantic matching. ,in
[0021]
[0022]
[0023] In the formula, For decoupled self-attention layers, For splicing operations, express Similarity to itself express and similarity, express and similarity, express Similarity to itself.
[0024] Furthermore, step S4 specifically includes the following steps:
[0025] S401, pedestrian characteristics Pedestrian features were separated from the two frames of images. pedestrian characteristics Transformed into m respectively and A two-dimensional feature descriptor, where c is the number of feature channels, and m and n are the number of pedestrians in the preceding and following frames, respectively; , And the characteristics of each pedestrian and Each feature is expanded into a one-dimensional feature vector, and pairwise Hadamard products are performed on each pedestrian feature to obtain m. The three-dimensional similarity matrix is used as the input to the discriminator;
[0026] S402. The similarity matrix is passed through a multilayer perceptron with a discriminator to obtain a logits vector map. The probability value of pedestrian matching is obtained through the softmax function. The number of people entering or leaving the city is distinguished based on the probability value. The total flow rate is obtained by summing the number of people entering the city.
[0027] Furthermore, step S402 specifically includes:
[0028] The similarity matrix is input into the discriminator's fully connected multilayer perceptron, and the output is m. The logits vector graph is used to obtain the probability value of each pair of pedestrian matches through the Softmax function. :
[0029]
[0030] in, For the sigmoid function, This represents a multilayer perceptron. Represents the Hadama product. The output is the matching probability. for exist The index number in the middle, for exist The index number in the database;
[0031] If the matching probability If the matching probability is greater than 0.5, the two rows are considered to be the same pedestrians in the preceding and following frames, and are not counted. If the matching probability is less than or equal to 0.5, the match is considered to have failed, and the pedestrians who were not matched in the following frame are treated as newly arriving pedestrians and counted once, thus obtaining the number of arriving pedestrians. and the number of people leaving ;
[0032]
[0033] in, The rounding symbol is used for rounding to the nearest integer.
[0034] The flow count result is the cumulative number of people entering the area. ,in, hour, That is, the total number of people detected in the first frame of the video stream.
[0035] Furthermore, in step S403, the multilayer perceptron is trained using the cross-entropy loss function and a one-to-many matching strategy is introduced, which allows pedestrians to be matched with themselves and other pedestrians in adjacent frames whose normalized distance is less than 0.2.
[0036] Furthermore, the one-to-many matching strategy is as follows:
[0037] The discriminator treats several adjacent pedestrians as small groups of people and performs one-to-many matching between pedestrians in the previous frame and small groups of people in the next frame. This matching strategy utilizes spatial location information, allowing a pedestrian to be matched with other pedestrians whose spatial locations are adjacent to it.
[0038] The beneficial effects of this invention are as follows:
[0039] (1) The method of this invention adopts a one-to-many matching method, which avoids the problem of sensitivity to appearance features and detection results caused by the one-to-one matching strategy. Through one-to-many matching, the movement characteristics of pedestrians walking in groups in public places are explored in depth, the movement patterns of small groups of people are fully explored, the counting accuracy of the model is improved, the model is more robust to different crowd densities in different scenarios, and at the same time, it can output intuitive visualization results.
[0040] (2) The present invention uses an implicit matching method for feature matching. The overall network architecture is simple and efficient, avoiding the need for manual setting and adjustment of relevant parameters, eliminating the sensitivity of the model to such parameters, and improving the accuracy of matching with this learnable matching method, thereby improving the counting accuracy. Attached Figure Description
[0041] Figure 1 This is a flowchart of the video pedestrian flow estimation method provided by the present invention;
[0042] Figure 2 This is a system framework diagram of the video pedestrian flow estimation method provided by the present invention;
[0043] Figure 3 This is a comparison diagram of the related tasks and related work provided by the present invention;
[0044] Figure 4 This is a comparison diagram of one-to-one matching and one-to-many matching provided by the present invention;
[0045] Figure 5 This is a diagram illustrating the phenomenon of a small group of people walking together, as provided by the present invention.
[0046] Figure 6These are a pair of original video frames containing pedestrians, provided by this invention.
[0047] Figure 7 This is a visualization of the one-to-many matching results provided by the present invention. Detailed Implementation
[0048] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0049] The application principle of the present invention will be further described below with reference to the accompanying drawings and specific embodiments.
[0050] The technical solution of this invention can be roughly divided into the following steps:
[0051] The first part involves localization and feature extraction from the video to be detected, using PET for pedestrian head localization and extracting pedestrian feature representations. The second part is the generation of matching context, which involves mining the similarity between pedestrian feature representations in consecutive frames to generate new pedestrian features with implicit matching relationships. The third part is the implementation of one-to-many matching, where a 3-layer perceptron judges the similarity vectors of pairwise pedestrian features to achieve one-to-many matching between people and groups, and finally outputs a traffic count. The traffic counting task addressed in this invention is a novel task distinct from multi-object tracking, cross-line counting, and pedestrian re-identification.
[0052] The detailed steps of the present invention are described below with reference to the accompanying drawings:
[0053] like Figure 1 As shown, a video pedestrian traffic estimation method based on a one-to-many matching strategy is presented, with the following specific steps:
[0054] S1. Periodically sample the video to obtain video frames. The universal head locator PET will be used to scan two consecutive frames of video images. Perform pedestrian detection and localization to obtain the coordinates of the pedestrian's head location;
[0055] S2. Based on the coordinates of the head positioning point, from two consecutive frames of images Pedestrian image patch in the middle and Image patches extracted using convolutional neural networks The appearance features of pedestrians are analyzed, and positional features are obtained by encoding the coordinates of head positioning points. The appearance features and positional features are then concatenated to obtain the pedestrian features. and The specific technical solution is as follows:
[0056] S201. Using the pedestrian's head coordinates as a reference point, analyze two consecutive frames of images... The size of the pixel containing the pedestrian in the middle is 1. The rectangular region was obtained using bilinear interpolation (an interpolation method that performs linear interpolation in two directions, which is existing technology). Pedestrian image patches of various sizes and ;
[0057] S202. Image patches are extracted using a convolutional neural network ConvNeXt-s. Pedestrian appearance features at a medium resolution of 1 / 32;
[0058] S203. Based on the coordinates of the pedestrian's head location point, a sinusoidal positional encoding is used to obtain a positional code with 256 channels. This code is then input into a one-dimensional convolutional layer with a kernel size of 1 to obtain a positional code with 1152 channels, thus acquiring the positional features. The sinusoidal positional encoding formula is as follows:
[0059]
[0060]
[0061] Where pos represents the position, i represents the dimension index, d represents the total dimension of the encoding, and PE is the position encoding;
[0062] S204. Combine the pedestrian's physical features with their location features to obtain the pedestrian features. and .
[0063] S3. Pedestrian features from two consecutive frames. and spliced into a matrix Then, the matrix is calculated using a decoupled multi-head self-attention mechanism. The similarity between elements is calculated, and the mean of the matching semantic part of the self-attention map is concatenated with the pedestrian features after the decoupled self-attention layer to obtain pedestrian features with enhanced matching semantics. The specific technical solution is as follows:
[0064] S301. Pedestrian features from two consecutive frames of images. and spliced as Four-dimensional pedestrian feature matrix After matrix transformation, the four-dimensional matrix is transformed. Flatten along spatial dimensions The 3D pedestrian feature matrix is obtained, and the number of channels is reduced to 256 through a 2D convolutional layer with a kernel of 1, resulting in a 256-dimensional pedestrian feature matrix. As input to the self-attention layer;
[0065] S302. Utilize an 8-head decoupled self-attention mechanism to process the 256-dimensional pedestrian feature matrix. Implicit feature matching is performed; in the self-attention layer, the 256-dimensional matrix is... Projection yields the query, key, and value (Q, K, V) used for self-attention computation. The self-attention mechanism then calculates the similarity between Q and K to obtain the self-attention graph. And through the calculation of V, new features with matching semantics are obtained. This enhances the semantic similarity between pedestrian features in two consecutive frames, including similar appearance features of the same pedestrian, similar position features of adjacent pedestrians, and similar appearance features of overlapping and occluded parts of adjacent pedestrians, so that pedestrian features have potential one-to-many semantic information.
[0066] S303, From Self-Attention Map Extract the pedestrian feature similarity component reflecting the two frames of images. Then, the average value is calculated along the spatial dimension and concatenated with the new features obtained through the self-attention layer. Obtain pedestrian features with enhanced matching semantics. The formula for this step is as follows:
[0067]
[0068]
[0069] in, For decoupled self-attention layers, For splicing operations, express Similarity to itself express and similarity, express and similarity, express Similarity to itself.
[0070] S4. Separating pedestrian features Pedestrian features were obtained from two frames of images. Calculate pedestrian features from two frames of images. The Hadamard product between the two frames yields a 3D similarity matrix. This similarity matrix is then input into a discriminator to predict pedestrian matching probabilities. Based on the matching results, the number of people flowing in or out is distinguished, and the total flow is obtained by summing the number of people flowing in from each frame. The specific technical solution is as follows:
[0071] S401, pedestrian characteristics Pedestrian features were separated from the two frames of images. pedestrian characteristics Transformed into m respectively and Two-dimensional feature descriptor, where c is the number of feature channels; , And the characteristics of each pedestrian and Each feature is expanded into a one-dimensional feature vector, and pairwise Hadamard products are performed on each pedestrian feature to obtain m. The three-dimensional similarity matrix is used as the input to the discriminator;
[0072] S402. The discriminator considers several adjacent pedestrians as small groups of people and performs one-to-many matching between pedestrians in the previous frame and small groups of people in the next frame. This matching strategy utilizes spatial location information, allowing a pedestrian to be matched with other pedestrians whose spatial locations are adjacent to it.
[0073] S403, the discriminator is a multilayer perceptron consisting of 3 fully connected layers, outputting a matching result with 2 channels, i.e., an m... The logits vector graph is used to obtain the probability value of each pair of pedestrian matches through the Softmax function. , representing the probability of a pedestrian being matched. Based on the matching results, the number of people flowing in or out is distinguished, and the total flow is obtained by summing the number of people flowing in from each frame.
[0074]
[0075] in, For the sigmoid function, This represents a multilayer perceptron. Represents the Hadama product. The output is the matching probability. for exist The index number in the middle, for exist The index number in the database;
[0076] S404, if the matching probability If the matching probability is greater than 0.5, the two rows are considered to be the same pedestrians in the preceding and following frames, and are not counted. If the matching probability is less than or equal to 0.5, the match is considered to have failed, and the pedestrians who were not matched in the following frame are treated as newly arriving pedestrians and counted once, thus obtaining the number of arriving pedestrians. and the number of people leaving .
[0077]
[0078] in, The rounding symbol is used for rounding to the nearest integer.
[0079] S405. Finally, the flow count result is the cumulative number of people entering the area. ,in, hour, That is, the total number of people detected in the first frame of the video stream.
[0080] In some embodiments, the training of the multilayer perceptron in steps S402 and S403 employs a cross-entropy loss function and introduces a one-to-many positive sample matching strategy. This strategy allows pedestrians to be matched with themselves and other pedestrians in adjacent frames whose normalized distance is less than 0.2. This achieves a one-to-many matching strategy that matches pedestrians with their respective small groups of people. Compared to the conventional one-to-one matching constraint, this strategy is more relaxed and robust. The specific differences are shown in the following equation:
[0081]
[0082] in, Represents the matching matrix. and Let them represent m-dimensional and n-dimensional column vectors, respectively. This is the maximum number of people in a small group.
[0083] In some embodiments, in steps S3 and S4, the Kullback-Leibler divergence between the discrete similarity distribution of the actual pedestrian feature matching pairs and the discrete similarity distribution of the predicted pedestrian feature matching pairs is used as one of the loss functions for model training. The mathematical formula is as follows:
[0084]
[0085] in, It is a smooth term. It is the discrete distribution of similarity between predicted pedestrian matching pairs. It is the discrete distribution of similarity between actual pedestrian matching pairs.
[0086] This invention provides a video pedestrian flow estimation method based on a one-to-many matching strategy. By processing and analyzing acquired video samples, the method infers the number of pedestrians flowing into and out of a location within a certain period, i.e., the flow rate. The functions and specific implementation processes of each module of the system are described in detail below, such as... Figure 2 and Figure 3 As shown.
[0087] (1) Feature extraction module, such as Figure 2 As shown in (a), the video sequence is first sampled at equal intervals of 3 seconds. The general head locator PET from Chengxin Liu, Hao Lu, Zhiguo Cao, and Tongliang Liu. Point-queryquadtree for crowd counting, localization, and more. IEEE International Conference on Computer Visio, 2023, pp. 1676–1685. performs head detection and localization on each video frame. The sampled video frame sequence is then paired, with adjacent frames forming a single pair. Each pair consists of two consecutive frames. Figure 6 The image sequence. Based on the coordinates of the head positioning point. Cut out where the pedestrian is A rectangular image patch, which is respectively... and The image patch is then interpolated using bilinear interpolation within a rectangular region defined by the coordinates of its top-left and bottom-right corners. The cropped pedestrian images are fed into the backbone network ConvNeXt-s to extract features, resulting in several pedestrian features with a resolution of 1 / 32 of the input resolution. To enable the model to perceive the spatial location of pedestrians, the location coordinates of each pedestrian are encoded and mapped through a one-dimensional convolutional layer, and then concatenated with the appearance features of the pedestrians to finally obtain the location-encoded pedestrian features.
[0088] (2) Implicit matching context generation module, such as Figure 2As shown in (b), the pedestrian features from two consecutive frames, after being encoded with location data, are input. The pedestrian feature vectors from the two frames are concatenated into a matrix, which is then projected and transformed to meet the shape requirements of the input dimension of the multi-head decoupled self-attention layer. This matrix is then input into a 6-layer, 8-head decoupled self-attention layer. Utilizing the decoupled self-attention mechanism, the similarity between features can be implicitly modeled. As shown in the following equation, the decoupled self-attention response map itself describes the similarity relationship between tokens. To further strengthen the similarity matching relationship, the decoupled self-attention map is used... A sub-graph describing the similarity between pedestrian features in the previous frame and pedestrian features in the next frame. The average value along its spatial dimension is compressed into one dimension and then concatenated with the new pedestrian features output by the self-attention layer that is decoupled from the multi-head, so as to finally obtain the pedestrian feature expression after matching semantic enhancement.
[0089]
[0090] (3) One-to-many pair matching module, the one-to-many matching strategy is as follows Figure 4 As shown, this module is as follows Figure 2 (c) First, the pedestrian feature matrix obtained from (2) is decomposed into pedestrian features of the previous frame and pedestrian features of the next frame. The Hadamard product is calculated for each pair of pedestrian features between the two frames to obtain the pairwise similarity matrix. This matrix is input into a 3-layer perceptron for judgment. The output result is processed by the Softmax function to obtain the probability of matching. If the probability is greater than 0.5, it is considered a match, that is, the two pedestrians are pedestrians common to both frames and are not counted; otherwise, they are not a match. If a pedestrian in the next frame cannot find a matching object among all pedestrians in the previous frame, then the pedestrian is a newly entered pedestrian in the next frame and is counted once. Finally, the predicted flow is the sum of all detected pedestrians in the first frame of the video sequence and all counted inflows in subsequent frames.
[0091] (4) One-to-many pair matching module, observed as follows Figure 5 The observed phenomenon of pedestrians tending to walk in groups is explored. To extract group information, enhance the model's robustness to changes in pedestrian appearance such as occlusion, and obtain more accurate and reliable prediction results, a one-to-many matching strategy is adopted. This strategy utilizes the cross-entropy loss function and introduces a one-to-many positive sample matching strategy, allowing pedestrians to be matched with themselves and other pedestrians in adjacent frames whose normalized distance is less than 0.2. This achieves a one-to-many matching strategy for small groups of pedestrians. When the input image is as follows... Figure 6 As shown, the one-to-many matching results are visualized as follows: Figure 7As shown, green dots represent pedestrians shared by two frames, red dots represent pedestrians flowing in and out, blue lines represent matching pedestrians, and red circles represent small groups of people.
[0092] (5) Model training: For the implicit matching context generation module described in (2), weakly supervised training is performed using the optimal transmission loss function as described in Xinyan Liu, Guorong Li, Yuankai Qi, Ziheng Yan, et al. Weakly supervised video individualcounting. IEEE Conference on Computer Vision and Pattern Recognition, 2024, pp. 19228–19237, to enable the model to distinguish feature similarity; for the one-to-many pair matching modules described in (3) and (4), the cross-entropy loss function is used, and the training strategy is as described in (4). In addition, in order to better supervise the entire network from a global perspective to improve stability, the Kullback-Leibler divergence between the discrete similarity distribution of actual pedestrian feature matching pairs and the discrete similarity distribution of predicted pedestrian feature matching pairs is calculated as one of the loss functions for model training, and its mathematical formula is as follows:
[0093]
[0094] in, It is a smooth term. It is the discrete distribution of similarity between predicted pedestrian matching pairs. It is the discrete distribution of similarity between actual pedestrian matching pairs.
[0095] The steps and specific implementation process of the video pedestrian flow estimation method based on one-to-many matching provided by this invention are consistent with the functions of the modules in the above system.
[0096] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A video pedestrian flow estimation method based on a one-to-many matching strategy, characterized in that, Includes the following steps: S1. Periodically sample the video to obtain video frames. To extract two consecutive frames from a video frame Perform pedestrian detection and localization to obtain the head coordinates of pedestrians; S2. Based on the head positioning coordinates, from two consecutive frames of images Pedestrian image patch in the middle and Image patches are extracted using convolutional neural networks. The appearance features of pedestrians are analyzed, and positional features are obtained by encoding the position using head positioning coordinates. The appearance features and positional features are then concatenated to obtain the pedestrian features. and ; S3. Pedestrian features from two consecutive frames. and spliced into a matrix Then, the matrix is calculated using a decoupled multi-head self-attention mechanism. The similarity between elements is used to obtain a self-attention map A. Pedestrian feature similarity is extracted from self-attention map A, and the mean of this similarity is concatenated with the semantically matched features obtained from self-attention map A to obtain semantically enhanced pedestrian features. ; S4. Separating pedestrian features Pedestrian features were obtained from two frames of images. Calculate pedestrian features from two frames of images. The Hadamard product between them yields a three-dimensional similarity matrix. The similarity matrix is then input into a discriminator to predict the pedestrian matching probability. Based on the matching probability, the number of people flowing in or out is distinguished, and the number of people flowing in from each frame is summed to obtain the total flow. The discriminator contains a three-layer multilayer perceptron, which is trained using the cross-entropy loss function and introduces a one-to-many matching strategy. That is, the discriminator treats several adjacent pedestrians as small groups of people and performs one-to-many matching between pedestrians in the previous frame and small groups of people in the next frame. This matching strategy utilizes spatial location information, allowing a pedestrian to be matched with other pedestrians whose spatial locations are adjacent to it.
2. The video pedestrian flow estimation method based on a one-to-many matching strategy according to claim 1, characterized in that, In step S1, a universal head locator (PET) is used to detect and locate pedestrians in the video frame image.
3. The video pedestrian flow estimation method based on a one-to-many matching strategy according to claim 1, characterized in that, Step S2 specifically includes the following steps: S201. Using the pedestrian's head coordinates as a reference point, analyze two consecutive frames of images... The pixel size of the pedestrian in the middle is 1. The rectangular region was obtained using bilinear interpolation. Pedestrian image patches of various sizes and ; S202. Image patches are extracted using a convolutional neural network ConvNeXt-s. Pedestrian appearance features at a medium resolution of 1 / 32; S203. Based on the coordinates of the pedestrian's head location point, sinusoidal position coding is used to obtain a position code with 256 channels. Inputting this into a one-dimensional convolutional layer with a kernel size of 1, a position code with 1152 channels is obtained, thus acquiring the position features. S204. Combine the pedestrian's physical features with their location features to obtain the pedestrian features. and .
4. The video pedestrian flow estimation method based on a one-to-many matching strategy according to claim 1, characterized in that, Step S3 includes: S301. Pedestrian features from two consecutive frames of images. and Concatenate into a four-dimensional pedestrian feature matrix The four-dimensional pedestrian feature matrix is transformed by matrix transformation. The feature matrix of pedestrians is obtained by flattening along the spatial dimension, and the number of channels is reduced to 256 by passing it through a two-dimensional convolutional layer with a kernel of 1, resulting in a 256-dimensional pedestrian feature matrix. As input to the self-attention layer; S302. Utilize a decoupled 8-head self-attention mechanism to process the 256-dimensional pedestrian feature matrix. Implicit feature matching is performed; in the self-attention layer, the 256-dimensional pedestrian feature matrix is analyzed. Projecting the query Q, key K, and value V, we obtain the self-attention graph by calculating the similarity between query Q and key K using a self-attention mechanism. Multiplying it with the value V yields features with semantic matching. ; S303, From Self-Attention Map Extract the pedestrian feature similarity component reflecting the two frames of images. Then, the pedestrian feature similarity part Calculate the average value along the spatial dimension , average With features By concatenating the features, we obtain pedestrian features with enhanced semantic matching. ,in In the formula, For decoupled self-attention layers, For splicing operations, express Similarity to itself express and similarity, express and similarity, express Similarity to itself.
5. The video pedestrian flow estimation method based on a one-to-many matching strategy according to claim 1, characterized in that, Step S4 specifically includes the following steps: S401, pedestrian characteristics Pedestrian features were separated from the two frames of images. pedestrian characteristics Transformed into m respectively and A two-dimensional feature descriptor, where c is the number of feature channels, and m and n are the number of pedestrians in the preceding and following frames, respectively; , And the characteristics of each pedestrian and Each feature is expanded into a one-dimensional feature vector, and pairwise Hadamard products are performed on each pedestrian feature to obtain m. The three-dimensional similarity matrix is used as the input to the discriminator; S402. The similarity matrix is passed through a multilayer perceptron with a discriminator to obtain a logits vector map. The probability value of pedestrian matching is obtained through the softmax function. The number of people entering or leaving the city is distinguished based on the probability value. The total flow rate is obtained by summing the number of people entering the city.
6. The video pedestrian flow estimation method based on a one-to-many matching strategy according to claim 5, characterized in that, Step S402 specifically includes: The similarity matrix is input into the discriminator's fully connected multilayer perceptron, and the output is m. The logits vector graph is used to obtain the probability value of each pair of pedestrian matches through the Softmax function. : in, For the sigmoid function, This represents a multilayer perceptron. Represents the Hadama product. The output is the matching probability. for exist The index number in the middle, for exist The index number in the database; If the matching probability If the matching probability is greater than 0.5, the two rows are considered to be the same pedestrians in the preceding and following frames, and are not counted. If the matching probability is less than or equal to 0.5, the match is considered to have failed, and the pedestrians who were not matched in the following frame are treated as newly arriving pedestrians and counted once, thus obtaining the number of arriving pedestrians. and the number of people leaving ; in, The rounding symbol is used for rounding to the nearest integer. The flow count result is the cumulative number of people entering the area. ,in, hour, That is, the total number of people detected in the first frame of the video stream.