Person gathering behavior recognition method and electronic device
By combining the YOLOv7 model and the DBSCAN clustering algorithm, adaptive recognition of crowd gathering behavior is achieved, which solves the error problem of existing algorithms under the image characteristics of near objects appearing larger and distant objects appearing smaller, and improves detection accuracy and robustness.
Patent Information
- Application Number
- CN202310489617.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-04
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2043-05-04
AI Technical Summary
Existing crowd gathering detection algorithms suffer from large errors when dealing with the image characteristics of near objects appearing larger and distant objects appearing smaller. They cannot adaptively adjust the distance between people in a region, are prone to missed detections or false alarms, and require a large amount of computation. They are also sensitive to complex backgrounds and have difficulty accurately judging crowd gathering behavior.
By adding a small target detection layer to the YOLOv7 target detection model and combining it with the DBSCAN clustering algorithm, the behavior of people gathering can be identified through adaptive calculation of regional distance and adaptive adjustment of cluster radius.
It improves the accuracy and robustness of crowd gathering judgment, reduces algorithm complexity and computational load, enhances the ability to identify crowd gathering, and reduces false alarms and missed detections.
Smart Images

Figure CN116363597B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image recognition, and in particular to a method and electronic device for recognizing crowd gathering behavior. Background Technology
[0002] Crowd detection is a crucial technology in the public security industry. Given an image or video, computers automatically process and analyze it to determine the number of people and whether a crowd gathering has occurred. In public safety management, public video surveillance can monitor the number of people and crowd gathering in each scene in real time, providing timely reports of gatherings so that managers can respond promptly and manage the situation. With the development of deep learning technology and the widespread and high-density installation of various surveillance cameras in cities, the demand for high-performance crowd detection algorithms is increasing. These algorithms must use deep learning and video surveillance to quickly detect illegal crowd gatherings in areas, obtain keyframes, and generate alarm images, thereby facilitating investigation and tracking by relevant agencies and departments, and enabling better management and law enforcement.
[0003] With the development of technology, the currently known published patents for detecting pedestrian gathering behavior are mainly divided into trajectory tracking-based, target detection-based, and image segmentation-based methods.
[0004] Trajectory-tracking-based crowd detection algorithms use target detection and multi-target tracking models to structurally label people's movement trajectories, traverse personnel information to divide them into clusters, and determine whether crowding has occurred, as in patent CN202210107678.4. This approach has a complex model, high computational cost, and is prone to losing targets when encountering occlusion, leading to inconsistent crowding detection. Target detection-based methods use traditional image processing or deep learning to extract pedestrian features for target detection and determine the number of people within a given small area of the image. If the number reaches a threshold, it is considered a crowd gathering, triggering an alarm, as in patent CN202011196406.3. This method is fast and logically simple, but it can only determine crowd gathering within a given area and cannot perform global image detection and alarm, thus having significant limitations in practical applications. The image segmentation-based method learns the background of the monitored area based on continuous video images, and performs pixel-by-pixel background subtraction and image segmentation operations on the video frames to obtain the target segmented image. Then, pixel statistics are performed on the target segmented image to determine whether there is a population gathering area, such as patent CN201510012881.3.
[0005] However, when a camera captures a picture, the resulting image typically includes both distant and background elements, causing the image to appear larger in the foreground and smaller in the background. This leads to a significant discrepancy between the actual distance represented by each pixel in the vertical direction of the image. Consequently, existing clustering methods may produce substantial errors in judging the distance between people in the image. For example, they might classify people who are far away as being close, and people who are close at hand as being close, resulting in poor judgment of crowd gathering behavior. In other words, these algorithms do not adapt to the size of the people's area and the distance to the camera, relying solely on simple image area segmentation for cluster judgment. This can easily lead to missed detections of distant crowds or false positives of nearby crowds. Moreover, image segmentation-based methods are computationally intensive, placing certain demands on the detection equipment. Furthermore, these methods are sensitive to background and clutter, making it difficult to obtain high-quality segmented images in complex backgrounds. Consequently, subsequent crowd gathering judgments are prone to ambiguity, easily mistaking background and clutter for crowds. Summary of the Invention
[0006] To address the aforementioned technical problems, this invention proposes a method and electronic device for recognizing crowd gathering behavior. The objective of this invention is achieved through the following technical solution:
[0007] A method for identifying crowd gathering behavior includes the following steps:
[0008] Establish an XY coordinate system, and divide the image of the monitored area captured by the camera into a regions along the Y-axis, numbered from bottom to top in the order A1, A2...Aa; a≥3; the Y-axis direction is the vertical direction of the image;
[0009] Several scaling ratio groups [S1, S2, ... Sa] for a regions are obtained in advance, as well as the ratio of the average head width of the bottom region to the average head width of the top region corresponding to each scaling ratio group, size_ratio;
[0010] Extract images from the video stream captured by the current camera, identify the center point of the head and the width of the head in each region of the image, form a set of coordinates of the center point of the head for each region, until the number of data in each set of coordinates of the center point of the head is greater than a preset threshold, and calculate the average width of the head in each region.
[0011] Calculate size_ratio, and then select the scaling ratio group corresponding to the calculated size_ratio as the scaling ratio for each region of the image captured by the current camera;
[0012] Set a threshold for the radius of people gathering. Based on the scaling ratio of each area, obtain the corrected distance between heads in each area and the corrected threshold for the radius of people gathering. Based on the corrected distance and the corrected threshold for the radius of people gathering, use a clustering algorithm to cluster the center point coordinates of heads in each image of the video stream. If the number of people in a certain cluster in an image is greater than the preset warning value, it is judged that people gathering has occurred.
[0013] As described above in the method for identifying crowd gathering behavior, a=4.
[0014] Further improvements include pre-determining four sets of scaling ratios for four regions. When size_ratio > 7, the corresponding scaling ratio set is [1.2, 1.4, 1.8, 2.3]; when 5 < size_ratio ≤ 7, the corresponding scaling ratio set is [1.2, 1.45, 1.7, 2]; when 3 < size_ratio ≤ 5, the corresponding scaling ratio set is [1.2, 1.4, 1.6, 1.8]; and when size_ratio ≤ 3, the corresponding scaling ratio set is [1.15, 1.3, 1.5, 1.7].
[0015] Further improvements are made by assuming the image length in the Y-axis direction is 1. Then the coordinate ranges of the four regions along the direction upward from the origin are [[0, 0.3], (0.3, 0.48], (0.48, 0.6], (0.6, 1]).
[0016] Further improvements include obtaining the corrected Y-axis coordinates of the head center point in each region's image based on the scaling ratio of each region. :
[0017] ;
[0018] Where y is the Y-axis coordinate of the center point of the human head before correction; S1, S2, S3, and S4 are the scaling ratios of the four regions from bottom to top, and Y is the Y-axis length of the video stream image.
[0019] Further improvements include adjusting the threshold for the radius of population aggregation in each region after correction. The method to obtain it is as follows:
[0020] ;
[0021] r1, r2, r3, and r4 are the index values of the four regions A1, A2, A3, and A4, respectively, used to map real-world distances to pixels in the image.
[0022] Further improvements involve using the YOLOv7 object detection model to obtain the minimum bounding box coordinates and center point coordinates of the human head image in the video stream.
[0023] As a further improvement, the YOLOv7 object detection model is equipped with a small object detection layer, and the feature map size corresponding to the small object detection layer is 160×160.
[0024] Further improvements include setting the preset threshold to 20.
[0025] An electronic device is characterized by a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method described above.
[0026] The beneficial effects of this invention are as follows:
[0027] This invention employs the YOLOv7 model as the head detection algorithm. Based on the original three detection layers of YOLOv7, a small target detection layer is added, with a corresponding feature map size of 160×160, increasing the target detection range and making it more suitable for detecting small head targets. Based on head detection information, adaptive regional distance calculation is performed on the video image, thereby adaptively adjusting the head distance information and adapting the cluster radius parameters in the DBSCAN clustering algorithm, enhancing the model's accuracy in judging personnel clusters. Compared with existing inventions, this invention, based on an optimized head detection model and an adaptive regional distance clustering algorithm, identifies and alarms on key frames of personnel clusters in surveillance video images, reducing the need for custom threshold definitions and improving the algorithm's robustness and accuracy. Compared with trajectory-based personnel clustering algorithms, it also reduces algorithm complexity and computational load. Attached Figure Description
[0028] The invention will be further illustrated with reference to the accompanying drawings, but the contents of the drawings do not constitute any limitation on the invention.
[0029] Figure 1 Here is a flowchart of the people gathering algorithm;
[0030] Figure 2 Image region segmentation diagram;
[0031] Figure 3 Initialize the average head width of the region;
[0032] Figure 4 For clustering effect Figure 1 ;
[0033] Figure 5 for Figure 4 The warning image;
[0034] Figure 6 For clustering effect Figure 2 ;
[0035] Figure 7 for Figure 6 The warning image;
[0036] Figure 8 For clustering effect Figure 3 ;
[0037] Figure 9 for Figure 8 The warning image;
[0038] Figure 10 For clustering effect Figure 4 ;
[0039] Figure 11 for Figure 10 The warning image. Implementation
[0040] To make the purpose, technical solution, and advantages of the invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and examples.
[0041] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0042] In the description of this application, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are used only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation on this application. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more features. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.
[0043] In this application, the term "exemplary" is used to mean "serving as an example, illustration, or description." Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to implement and use this application. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that this application can be implemented without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid obscuring the description of this application with unnecessary detail. Therefore, this application is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.
[0044] In this invention patent, a method for recognizing crowd gathering behavior based on a regional distance adaptive clustering algorithm is proposed to address existing problems. (Reference) Figure 1 As shown, the first steps involve data input configuration and aggregation configuration. Users select online or offline video data to input, configure the video frame interval, and then configure aggregation, including the area to be detected, the threshold for the number of people in aggregation, and the aggregation radius. After these steps, the input video data is processed by the algorithm. The algorithm uses a target detection model enhanced for small target detection to detect pedestrians. It then calculates the mean value of the number of heads in the detected area using the head bounding boxes. This mean value is then input into a vertical distance adaptive function to adaptively correct the vertical distance of the detected head center points. Simultaneously, the mean value is input into a clustering radius adaptive function to determine the clustering radius for each person. Based on the vertically corrected head points and the adaptive clustering radius, DBSCAN adaptive clustering is performed. Finally, the clustering results using the head center points determine whether pedestrian aggregation has occurred. If aggregation is confirmed, keyframe images of the aggregation are captured, alarm information is generated, and saved and displayed.
[0045] The specific steps of this invention are as follows:
[0046] A method for identifying crowd gathering behavior, reference Figure 1 As shown, it includes the following steps:
[0047] S101. Sample the decoded online or offline video to obtain image frame information and divide it into four regions [A1, A2, A3, A4].
[0048] Because images exhibit the characteristic of appearing larger when closer and smaller when farther away—meaning that people at the bottom of the image are closer to the camera, resulting in a larger imaging range, while people at the top are farther away, resulting in a smaller imaging range—if the size of an object is calculated based on a fixed ratio of pixels to its actual length and width, the calculated size and spacing of people at the top of the image will be much smaller than their actual size and spacing, while the calculated size and spacing of people at close range may be larger than their actual size and spacing. This can lead to misjudgments of the distance between people and false alarms when detecting people gathering together.
[0049] Therefore, to achieve adaptive estimation, this invention first divides the input image into regions to facilitate subsequent calculations. In practical applications, the upper part of the image is often the sky and far-end regions, the upper middle part is the far-end region, the lower middle part is the near-end region, and the lower part is the near-end region. Therefore, the input image is divided along the Y-axis into four regions [A1, A2, A3, A4] using the ratio ranges [[0, 0.3], (0.3, 0.48], (0.48, 0.6], (0.6, 1]]. Figure 2 As shown.
[0050] S102. Traverse the initial image and use the improved YOLOv7 detection algorithm to obtain head information in each region until the number of heads in each region exceeds 20. If the coordinate overlap in a certain region is very high, randomly delete some coordinates (if the standard deviation of the head width in a certain region is greater than the preset threshold, it indicates that the coordinate overlap is very high. In this invention, the preset thresholds for the four regions A1-A4 are 7, 5, 4, and 2, respectively, in pixels). After the number of heads in each region is not less than 20, obtain the average head width [w1, w2, w3, w4] in the four regions.
[0051] Firstly, when using the YOLOv7 detection algorithm, targeted data augmentation and model optimization were performed on the YOLOv7 detection algorithm model. Specifically, on the data side, data augmentation methods such as Mosaic, MixUp, and Random Affine were used to improve model accuracy. On the model side, based on the original three sets of initialization values (20×20, 40×40, and 80×80), a new set of anchor values for detecting small targets was added, i.e., a small target detection layer was added. When the input size is 640×640, the feature map size corresponding to the added small target detection layer is 160×160. Mapping it to a 1920×1080 image, the minimum detection target changed from (24, 13.5) to (12, 6.75), increasing the target detection range and making it more suitable for head detection of small targets. Furthermore, an attention mechanism, such as SEnet Block, was added to the backbone network of the YOLOv7 detection algorithm model to learn the weight relationships between different channels, improving the network's accuracy. SEnet Block, proposed by Momenta in September 2017, enhances the representational power of networks by explicitly modeling the interdependencies between convolutional feature channels. Specifically, the channel-dimensional attention mechanism, unlike conventional convolution operations where the results of each channel's computation are summed and output, derives equal importance from the output. The channel-dimensional attention mechanism, however, learns to automatically acquire the importance of each feature channel (i.e., the weights of the feature map layer), thereby enhancing useful channel features and suppressing unimportant ones.
[0052] This invention patent uses an improved YOLOv7 detection algorithm for human target detection. Through the data processing and training methods described above, a head detection model capable of completely selecting heads in various scenarios is obtained. By extracting frames from online or offline video streams at set intervals and inputting the images into the trained head detection model, the rectangular bounding box coordinates, center point coordinates, and positional accuracy of the head are obtained.
[0053] S103. Based on the ratio of the average head width in regions A1 and A4, determine the vertical adaptive scaling ratio of the video at the current location [S1, S2, S3, S4].
[0054] Before calculating the average head width, an initialization process is required, which involves calculating head information within the defined regions. The process is as follows: Figure 3As shown. The initialization process is as follows: a) First, collect the center point coordinates and radius of N (N>5) heads; b) Sort according to the y coordinate of the center point so that there are heads covering all four small areas; c) If the y coordinate overlap of a certain small area in b is very high, randomly delete some coordinate points and replace them with new head points until the number of head points in each small area is greater than 20; d) Calculate the average width of the head in each area to obtain [w1, w2, w3, w4].
[0055] The specific steps are as follows: Figure 3 As shown:
[0056] S1031, Obtain video data.
[0057] S1032, Obtain the image frame.
[0058] S1033, The head detection algorithm in the YOLOv7 detection algorithm is adopted.
[0059] S1034: Obtain the coordinates of the center point of the head frame and the size of the head frame.
[0060] S1035. Add the obtained coordinates of the center point of the head frame and the size of the head frame to the set of the region.
[0061] S1036. Determine if the number of data sets in the region is greater than 5. If yes, proceed to the next step; otherwise, return to step S1032 and continue to obtain image frames.
[0062] S1037. Calculate the standard deviation of the head width pixels in each region;
[0063] S1038. Determine whether the standard deviation of the region is greater than the region threshold. If not, proceed to step S1039; if yes, proceed to step S10310.
[0064] S1039. Randomly delete the coordinates of the center points of some heads, then return to step S1032 to continue obtaining image frames;
[0065] S10310. Determine if the number of data sets in the region is greater than 20. If yes, end the process; otherwise, return to step S1032 to continue obtaining image frames.
[0066] S104. Based on the detection algorithm, perform head detection in the current frame, and use the vertical distance adaptive function h(y) to adaptively scale the vertical distance of the detected head center point.
[0067] Since the distance scale along the same horizontal line in an image tends to be consistent, while the distance scale along the same vertical line exhibits a non-linear change due to the principle of near objects appearing larger and farther objects appearing smaller, the vertical value (i.e., the y-value) of the head center point should be appropriately corrected for more reasonable clustering judgment. The correction scheme is as follows: a) Based on the ratio of the average width of the head in the farthest region A4 to the average width of the head in the nearest region A1, select the scaling ratios [S1, S2, S3, S4] for each region, where the scaling ratios are several preset values; b) Calculate the corrected y-value based on the vertical distance adaptive function h(y):
[0068] ;
[0069] Where Y represents the width of the image, y is the vertical coordinate of the center point of the head, S1, S2, S3, S4 are the adaptive scaling ratios of the four regions respectively, and A1, A2, A3, A4 represent the four regions respectively.
[0070] Four sets of scaling ratios for four regions were pre-determined. When size_ratio > 7, the corresponding scaling ratio set is [1.2, 1.4, 1.8, 2.3]; when 5 < size_ratio ≤ 7, the corresponding scaling ratio set is [1.2, 1.45, 1.7, 2]; when 3 < size_ratio ≤ 5, the corresponding scaling ratio set is [1.2, 1.4, 1.6, 1.8]; and when size_ratio ≤ 3, the corresponding scaling ratio set is [1.15, 1.3, 1.5, 1.7].
[0071] S105. Calculate the cluster radius index value for each region. The cluster radius of each head in the current frame is determined by using the longitudinal distance adaptive function h(y).
[0072] S106. Traverse the head center point information in the current frame. Using the clustering radius of each head obtained in S105, use the DBSCAN clustering algorithm to perform clustering judgment on the vertically adaptive head center points. If the number of people in a certain class is greater than the preset threshold, it is determined that a clustering phenomenon has occurred.
[0073] This invention patent employs the DBSCAN (Density-Based Spatial Clustering of Applications with Noise) clustering algorithm, which is a representative density-based clustering algorithm. Unlike partitioning and hierarchical clustering methods, it defines a cluster as the largest set of density-connected points, enabling it to divide regions with sufficiently high density into clusters and discover clusters of arbitrary shapes in noisy spatial databases.
[0074] DBSCAN clustering algorithm description:
[0075] Input: A database containing n objects, radius e, minimum number of objects (MinPts);
[0076] Output: All generated clusters meet the density requirements.
[0077] (1) Repeat
[0078] (2) Extract an unprocessed point from the database;
[0079] (3) If the extracted point is the core point, then find all objects that are density-connected to that point to form a cluster;
[0080] (4) If the extracted point is an edge point (non-core object), exit the current loop and find the next point;
[0081] (5) Continue until all points have been processed.
[0082] DBScan requires two parameters: scan radius (eps) and minimum number of points to include (minPts). It starts with any unvisited point and finds all nearby points within (and including) eps.
[0083] If the number of nearby points is greater than or equal to minPts, then the current point and its nearby points form a cluster, and the starting point is marked as visited. Then, recursively, all unvisited points within the cluster are processed in the same way, thereby expanding the cluster.
[0084] If the number of nearby points is less than minPts, the point is temporarily marked as a noise point.
[0085] If the cluster is sufficiently expanded, meaning all points within the cluster are marked as visited, then the same algorithm is used to process the unvisited points.
[0086] Since the DBSCAN clustering algorithm itself cannot adapt to the transformation of near objects being larger than distant ones, it is necessary to determine the clustering radius of the current head position based on the information of the region where the center point is located; the specific steps are as follows: a) First, calculate the clustering radius index value based on the average width of the head in the region obtained in (5):
[0087]
[0088] Where n is the clustering coefficient, which needs to be calculated based on the personnel clustering radius threshold. For example, if the personnel clustering radius threshold is set to 1 meter, based on experience, the average width of the head frame is 0.2 meters. Then, the actual distance between pixels in different regions of the image is approximately 0.2 / w meters. If the clustering radius is set to 1 meter, the corresponding pixel distance in the image is 1 / (0.2 / w), which is 5w. Therefore, the clustering coefficient n=5; b) Determine the clustering radius of each point based on the adaptive function r(y) of the clustering radius:
[0089]
[0090] Where Y represents the width of the image; c) Based on the clustering radius information obtained in b, and using the DBSCAN density clustering algorithm, clustering calculations are performed on the coordinates of the head center points in the image, which have been corrected by the longitudinal distance adaptive function h(y). The calculation results are as follows: Figure 4 As shown.
[0091] This invention has found that if the y / Y value is also divided into four regions for clustering, the clustering effect is poor. This is because the distance between different pixels at the bottom and top of the image and the camera is different, resulting in different actual lengths and widths represented by pixels at different vertical coordinates, and the changes are non-linear. Dividing the y / Y value according to the method in step S101 will lead to a large error and poor recognition effect. Therefore, this invention sets two more regions within each region based on the four regions divided in step S101, so that the results are more accurate, and the number of regions is not large, so the amount of computation is not too large.
[0092] In this invention, the range values of each region, the values of each scaling ratio group, and the range of y / Y in the adaptive clustering radius function r(y) are all obtained through debugging. Specifically, a number of manually labeled images as clusters of people are taken as positive samples, and a number of manually labeled images as non-clustered images are taken as negative samples. Then, the division range of each region is adjusted, and the scaling ratio, the corresponding size_ratio value, and the y / Y range of each region are manually adjusted until the accuracy of correctly identifying clusters of people is above a preset value, typically above 90%, preferably 95%. The above process can undoubtedly also be automatically obtained by setting up a computer script.
[0093] Based on the clustering results in step S106, it can be determined whether a crowd gathering phenomenon has occurred. If the heads in the image cluster into a group, and the number of people in a certain group exceeds a preset threshold, then clustering is determined to have occurred, i.e., crowd gathering, and an alarm is immediately generated. If crowd gathering still exists in this area after 5 seconds, an alarm is generated again. The alarm image is as follows. Figure 5 As shown.
[0094] This invention primarily targets scenarios involving large gatherings of people in urban video surveillance. Users need to set up online or offline video streams, configure the video frame extraction frequency, define the detection area, and set thresholds for the number of people gathered and the radius of the gathering. When user data configuration errors occur, such as incorrect video addresses or video stream acquisition failures, the algorithm will provide corresponding prompts.
[0095] Specifically, before using this invention, data input and aggregation configurations must be performed. Users input online or offline video data, configure the video frame interval, and then configure aggregation, including the area to be detected, the threshold for the number of people in the aggregation, and the aggregation radius. After these operations are completed, the input video data can be processed using the aforementioned algorithm. The algorithm of this invention uses a target detection model enhanced for small target detection to detect pedestrians. Then, it calculates the mean value of the number of people in the region using the detected head bounding boxes. This mean value information is then input into a longitudinal distance adaptive function to adaptively correct the longitudinal distance of the detected head center points. Simultaneously, the mean value information is input into a clustering radius adaptive function to determine the clustering radius for each person. Then, based on the longitudinally corrected head points and the adaptive clustering radius, DBSCAN adaptive clustering is performed. Finally, the clustering results using the head center points determine whether pedestrian aggregation behavior has occurred. If confirmed, keyframe images of the aggregation are captured to generate alarm information for saving and display.
[0096] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for recognizing crowd gathering behavior, characterized in that: Includes the following steps: Establish an XY coordinate system, and divide the image of the monitored area captured by the camera into a regions along the Y-axis, numbered from bottom to top in the order A1, A2...Aa; a≥3; the Y-axis direction is the vertical direction of the image; Several scaling ratio groups [S1, S2, ... Sa] for a regions are obtained in advance, as well as the ratio of the average head width of the bottom region to the average head width of the top region corresponding to each scaling ratio group, size_ratio; Extract images from the video stream captured by the current camera, identify the center point of the head and the width of the head in each region of the image, form a set of coordinates of the center point of the head for each region, until the number of data in each set of coordinates of the center point of the head is greater than a preset threshold, and calculate the average width of the head in each region. Calculate size_ratio, and then select the scaling ratio group corresponding to the calculated size_ratio as the scaling ratio for each region of the image captured by the current camera; Set a threshold for the radius of people gathering. Based on the scaling ratio of each area, obtain the corrected distance between heads in each area and the corrected threshold for the radius of people gathering. Based on the corrected distance and the threshold for the radius of people gathering, use a clustering algorithm to cluster the center point coordinates of the heads in each image of the video stream. If the number of people in a certain cluster in an image is greater than the preset warning value, it is judged that people gathering has occurred. Specifically, the YOLOv7 object detection model is used to obtain the minimum bounding box coordinates and center point coordinates of the human head image in the video stream; the YOLOv7 object detection model is equipped with a small object detection layer, and the feature map size corresponding to the small object detection layer is 160×160.
2. The method for identifying crowd gathering behavior as described in claim 1, characterized in that: a=4。 3. The method for recognizing crowd gathering behavior as described in claim 2, characterized in that: Four sets of scaling ratios for four regions are obtained in advance. When size_ratio > 7, the corresponding scaling ratio group is [1.2, 1.4, 1.8, 2.3], when 5 < size_ratio ≤ 7, the corresponding scaling ratio group is [1.2, 1.45, 1.7, 2], when 3 < size_ratio ≤ 5, the corresponding scaling ratio group is [1.2, 1.4, 1.6, 1.8], and when size_ratio ≤ 3, the corresponding scaling ratio group is [1.15, 1.3, 1.5, 1.7].
4. The method for recognizing crowd gathering behavior as described in claim 2, characterized in that: If the length of the image along the Y-axis is 1, then the coordinate ranges of the four regions along the direction upward from the origin are [[0,0.3), (0.3,0.48], (0.48,0.6], (0.6,1]].
5. The method for recognizing crowd gathering behavior as described in claim 4, characterized in that: Based on the scaling ratio of each region, the corrected Y-axis coordinate h(y) of the center point of the human head in each region's image is obtained: Where y is the Y-axis coordinate of the center point of the human head before correction; S1, S2, S3, and S4 are the scaling ratios of the four regions from bottom to top, respectively, and Y is the Y-axis length of the video stream image; A1, A2, A3, and A4 represent regions.
6. The method for recognizing crowd gathering behavior as described in claim 5, characterized in that: The method for obtaining the corrected population aggregation radius threshold r(y) for each region is as follows: r1, r2, r3, and r4 are the index values of the four regions A1, A2, A3, and A4, respectively, used to map real-world distances to pixels in the image.
7. The method for recognizing crowd gathering behavior as described in claim 1, characterized in that: The preset threshold is 20.
8. An electronic device, characterized in that, A memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Personnel gathering detection method based on video images
CN104658008A
A method and device for detecting crowd gathering
CN114494350B
A method and system for analyzing the situation of people gathering
CN114529860B
Method, system and device for detecting personnel aggregation and storage medium
CN115761636A
Cross-video person location tracking method and system, and device
WO2021196294A1