Backward personnel detection method and device, computer device and storage medium
By adding a face orientation prediction branch to the YOLOv5 model and a sparse optical flow method to the Bytetrack model, combined with face orientation angle judgment, the problems of false detection and missed detection in the detection of people walking against the flow at subway stations are solved, achieving higher detection accuracy and precision.
Patent Information
- Application Number
- CN202210141001.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-16
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-02-16
AI Technical Summary
The existing technology for detecting people walking against the flow at subway stations has problems such as high false detection rate and missed detection targets in crowded environments, especially the inability to accurately determine whether a passenger is walking against the flow between multiple input videos.
The YOLOv5 model is used for facial target frame detection and face orientation prediction, combined with the Bytetrack model for target tracking. The sparse optical flow method is used to track the target, and the face orientation angle is used to determine whether the passenger is driving against traffic. The same face index is marked through similarity comparison within the video shooting range to improve detection accuracy.
It improves the accuracy of detecting people walking against traffic, reduces missed detections in crowded areas, and enhances the detection accuracy between multiple videos.
Smart Images

Figure CN114494975B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a public monitoring method, and more specifically to a method, device, computer equipment and storage medium for detecting people walking against traffic. Background Art
[0002] With the acceleration of urbanization, subways have become increasingly important in public transportation. Some subway stations, especially transfer stations, have one-way traffic areas. Pedestrians walking against traffic in these one-way passages can easily cause stampedes if a sudden surge of passengers arrives at the station.
[0003] Chinese patent CN2020106811388 discloses a method for counting passenger flow in subway sections and detecting pedestrians walking against traffic based on a multi-target tracking algorithm. The invention applies an online multi-target tracking algorithm to subway monitoring scenarios, uses subway monitoring videos to create a sample set for training detectors, and uses a large-scale pedestrian re-identification dataset to train an appearance feature extraction network. The algorithm integrates motion information and appearance features to improve the performance of the tracking algorithm. The algorithm tracks each pedestrian target in the scene and then detects pedestrians walking against traffic. However, it only considers the trajectory of human position movement and ignores human orientation information. For pedestrians avoiding obstacles or retreating, this method is prone to false detection and has certain limitations. At the same time, it does not consider the fusion between multiple input videos. For passengers walking across camera areas, it is impossible to determine whether the passenger is walking against traffic. Chinese patent CN201810788375.9 discloses a method for detecting pedestrians walking against traffic in subway stations based on video analysis. The method includes the following logic: first, obtaining a video stream, modeling the background of the monitoring area through a mixed Gaussian model, then extracting the motion foreground, and determining whether there is a pedestrian in the image through a convolutional neural network pedestrian contour segmentation model. Then the direction of the pedestrian is tracked and determined. If a pedestrian is found walking in the wrong direction, an alarm is issued. However, this technical solution uses a mixed Gaussian model to model the monitoring area, which is easily affected by environmental factors such as lighting, and the effect is unstable.
[0004] Therefore, it is necessary to design a new method to improve the accuracy of reverse detection of people and make up for the situation where deep learning detection targets are missed due to dense crowds. Summary of the Invention
[0005] The purpose of the present invention is to overcome the defects of the prior art and provide a method, device, computer equipment and storage medium for detecting people walking against the flow.
[0006] To achieve the above-mentioned purpose, the present invention adopts the following technical solution: a method for detecting people walking against traffic, comprising:
[0007] Obtain the video captured by the camera and process the video to obtain the image to be detected;
[0008] Input the image to be detected into the target detection model to detect the human face target frame and predict the face orientation angle to obtain the detection result;
[0009] Inputting the detection results into a tracking model to perform target tracking to obtain a tracking trajectory result;
[0010] Determine a target angle based on the tracking trajectory result and the face orientation angle, and determine whether the corresponding passenger is a person walking against traffic based on the target angle;
[0011] If the corresponding passenger is a person walking against traffic, a warning message for walking against traffic is generated and sent to the terminal.
[0012] Its further technical solution is: the target detection model is formed by adding a face orientation prediction branch to the YOLOv5 model.
[0013] A further technical solution is: inputting the image to be detected into the target detection model to detect the face target frame and predict the face orientation angle to obtain the detection result, including:
[0014] Input the image to be detected into the target detection model to detect the target frame of the human face;
[0015] According to the facial target frame, feature mapping is performed from the N2 layer and the N3 layer of the YOLOv5 model based on the ROI Align mechanism and the SPP method to obtain facial features;
[0016] The original features are spliced according to the facial features to obtain the fusion features;
[0017] The face orientation angle is predicted based on the fusion features through the global average pooling, fully connected layer, and face orientation prediction branch of the YOLOv5 model, and the predicted face orientation angle is integrated with the face target frame to obtain a detection result.
[0018] Its further technical solution is: the tracking model is formed by adding a sparse optical flow method on the basis of the Bytetrack model. Among them, when the tracking model uses the Bytetrack model to track the target and the target is not detected within a specified number of consecutive frames, the optical flow tracking of the target is advanced by several frames from the moment of disappearance until the target is found within the specified number of frames, and then the Bytetrack model is continued to be used for target tracking.
[0019] A further technical solution is: determining the target angle according to the tracking trajectory result and the face orientation angle includes:
[0020] determine a tracking orientation angle according to the tracking trajectory result;
[0021] determine a target angle according to the tracking orientation angle and a face orientation angle.
[0022] Further technical solutions thereof are that the determining whether the corresponding passenger is a reverse person according to the target angle comprises:
[0023] calculating a difference between the target angle and a preset reverse face angle;
[0024] determining whether the difference exceeds a set threshold value;
[0025] if the difference exceeds the set threshold value, determining that the corresponding passenger is a reverse person;
[0026] if the difference does not exceed the set threshold value, determining that the corresponding passenger is not a reverse person.
[0027] Further technical solutions thereof are that the splicing original features according to face features to obtain fused features further comprises:
[0028] splicing original features according to face features to obtain fused features, and when the similarity between the fused features of the passenger within a certain threshold value of the picture edge in the video shooting range and the fused features of the passenger in the picture to be detected of the adjacent camera is less than a set threshold value of similarity, marking the two fused features as the same face index.
[0029] The application further provides a reverse person detection device, comprising:
[0030] a sampling unit configured to acquire a video shot by a camera and process the video to obtain a picture to be detected;
[0031] a target detection unit configured to input the picture to be detected into a target detection model to detect a face target frame and predict a face orientation angle, so as to obtain a detection result;
[0032] a target tracking unit configured to input the detection result into a tracking model to perform target tracking, so as to obtain a tracking trajectory result;
[0033] an angle determination unit configured to determine a target angle according to the tracking trajectory result and the face orientation angle;
[0034] a determination unit configured to determine whether the corresponding passenger is a reverse person according to the target angle;
[0035] an alarm unit configured to generate reverse alarm information if the corresponding passenger is a reverse person, and send the reverse alarm information to a terminal.
[0036] The present invention further provides a computer device, comprising a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above method when executing the computer program.
[0037] The present invention also provides a storage medium, wherein the storage medium stores a computer program, and the computer program implements the above method when executed by a processor.
[0038] The beneficial effects of the present invention compared with the prior art are: the present invention obtains the image taken by the camera and cuts it, so as to detect the human face target frame and predict the face direction in the generated target detection model of the image to be detected, combines the tracking model to track the target, and determines the face direction angle according to the tracking trajectory result. When the corresponding passenger is a person walking against the flow, an alarm is issued to improve the accuracy of the detection of people walking against the flow, and make up for the situation where deep learning detection targets are missed due to dense crowds.
[0039] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1 A schematic diagram of an application scenario of the method for detecting people walking against traffic provided by an embodiment of the present invention;
[0042] Figure 2 A schematic diagram of a flow chart of a method for detecting people walking against traffic provided by an embodiment of the present invention;
[0043] Figure 3 A schematic diagram of a sub-process of a method for detecting a person walking against traffic provided by an embodiment of the present invention;
[0044] Figure 4 A schematic diagram of a sub-process of a method for detecting a person walking against traffic provided by an embodiment of the present invention;
[0045] Figure 5 A schematic diagram of a sub-process of a method for detecting a person walking against traffic provided by an embodiment of the present invention;
[0046] Figure 6 A schematic block diagram of a device for detecting people walking against traffic provided by an embodiment of the present invention;
[0047] Figure 7 A schematic block diagram of a target detection unit of a wrong-walking person detection device provided by an embodiment of the present invention;
[0048] Figure 8 A schematic block diagram of an angle determination unit of a wrong-walking person detection device provided by an embodiment of the present invention;
[0049] Figure 9 A schematic block diagram of a judgment unit of a wrong-walking person detection device provided by an embodiment of the present invention;
[0050] Figure 10 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0051] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0052] It will be understood that when used in this specification and the appended claims, the terms “comprises” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0053] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the present invention. As used in the specification and appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0054] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0055] See also Figure 1 and Figure 2 , Figure 1 Schematic diagram of an application scenario of the method for detecting people walking against traffic provided by an embodiment of the present invention. Figure 2A schematic flow chart of a method for detecting people walking against traffic provided by an embodiment of the present invention. The method for detecting people walking against traffic is applied to a server. The server exchanges data with a terminal and a camera, obtains a video shot by the camera, processes the video to form a picture to be detected, and uses a target detection model to detect a target frame of a human face and predict the direction of the human face, and uses a tracking model to track the target, and then determines the direction of the human face. It determines whether the corresponding passenger is a person walking against traffic based on the target angle. When the corresponding passenger is a person walking against traffic, a warning message for walking against traffic is generated and sent to the terminal. For pedestrians avoiding obstacles or retreating, not only the direction of the movement trajectory is considered, but also the direction of the pedestrian's face is considered, making the estimation of the pedestrian's direction more robust and more accurate. In the process of target tracking, the recall rate of tracking is increased by adding the optical flow method, and the target missed in the target detection can also be well captured, thereby improving the accuracy of the direction of human movement, achieving an improvement in the accuracy of people walking against traffic detection, and compensating for the situation where deep learning detection targets are missed due to dense crowds.
[0056] Figure 2 FIG. 1 is a flow chart of a method for detecting people walking against traffic provided by an embodiment of the present invention. Figure 2 As shown, the method includes the following steps S110 to S160.
[0057] S110: Obtain the video captured by the camera and process the video to obtain a picture to be detected.
[0058] In this embodiment, the image to be detected refers to an image captured by a camera within a set gate range.
[0059] Specifically, the optical camera is aimed at the area to be monitored for wrong-way driving, and the area is monitored using a video-based method. The optical camera uses a fixed focal length, fixed angle, and fixed position. The captured video is sliced to generate images. Here, every two frames are sliced to generate a time-series frame image, which is the image to be detected. Relying solely on the optical camera saves significant costs.
[0060] S120: Input the image to be detected into a target detection model to detect a human face target frame and predict a human face orientation angle to obtain a detection result.
[0061] In this embodiment, the detection result refers to the specific location of the face and the direction of the face.
[0062] Specifically, the target detection model is formed by adding a face orientation prediction branch to the YOLOv5 model.
[0063] In one embodiment, see Figure 3, the above-mentioned step S120 may include steps S121 to S124.
[0064] S121: Input the image to be detected into a target detection model to detect a human face target frame.
[0065] In this embodiment, the face target frame refers to the specific position of the passenger's face in the image to be detected.
[0066] The use of the YOLOv5 model to detect the face target frame belongs to the existing technology and will not be elaborated here.
[0067] S122: Perform feature mapping from the N2 layer and the N3 layer of the YOLOv5 model based on the ROI Align mechanism and the SPP method according to the facial target frame to obtain facial features.
[0068] In this embodiment, the facial features are based on the features of the facial region on the feature map.
[0069] A face orientation branch is added to the YOLOv5 model. Because the face orientation accounts for a relatively small proportion of the human body, the N2 and N3 layers are selected as feature layers in the PANet model, i.e., the YOLOv5 model. These two feature layers have a small receptive field and can detect features of the face and facial area well.
[0070] Performing feature extraction of multiple residual modules simultaneously on different feature layers can keep the two features of the same size.
[0071] S123. Splicing original features according to facial features to obtain fused features.
[0072] In this embodiment, the fusion feature is the face splicing face based on the features mapped out by the N1 feature layer and the N2 feature layer to perform concatenation fusion FF (face feature).
[0073] Specifically, the original features are spliced according to the facial features to obtain the fused features, and when the similarity between the fused features corresponding to the passengers within a certain threshold of the edge of the picture within the video shooting range and the fused features corresponding to the images to be detected by other adjacent cameras is less than the similarity set threshold, the two fused features are marked as the same face index.
[0074] For passengers about to leave within a certain threshold from the edge of the video capture range, the FF features in the target detection model are retained. For passengers about to enter within a certain threshold from the edge of the video capture range, the HF features in the target detection model are compared with the retained FF features of other adjacent camera samples for similarity. If the similarity is less than a certain threshold, the two people are considered to be the same person, that is, they have the same index, further solving the problem of inaccurate retrograde detection in the area due to the inability to connect across videos. Based on facial feature similarity, it solves the problem of inaccurate retrograde judgment in the area due to the inability to accurately match people across multiple camera devices.
[0075] S124. Predict the face orientation angle through the global average pooling, fully connected layer, and face orientation prediction branch of the YOLOv5 model based on the fusion features, and integrate the predicted face orientation angle with the face target frame to obtain a detection result.
[0076] When training the target detection model, the loss function is Among them, α is the angle corresponding to the predicted face orientation, and β is the angle corresponding to the actual face orientation.
[0077] The target detection model can detect the face target frame while also detecting the face orientation, which improves the model's operating efficiency. At the same time, the information based on the instantaneous face orientation plays a certain auxiliary role in judging the direction of pedestrian movement, thereby improving the accuracy of detecting people walking in the opposite direction.
[0078] S130: Input the detection result into a tracking model to perform target tracking to obtain a tracking trajectory result.
[0079] In this embodiment, the tracking trajectory result refers to the movement trajectory of the human body, that is, the behavior trajectory of the passenger.
[0080] In this embodiment, the tracking model is formed by adding a sparse optical flow method to the Bytetrack model. When the tracking model uses the Bytetrack model to track a target and the target is not detected within a specified number of consecutive frames, the optical flow tracking of the target is advanced by several frames from the moment it disappears. Until the target is found within the specified number of frames, the Bytetrack model is continued to be used for target tracking.
[0081] The tracking model not only tracks the trajectory of human targets through deep learning, but also incorporates optical flow method for target tracking as an auxiliary, which can effectively solve the problem of missed detection of targets due to deep learning detection in crowded environments.
[0082] Specifically, if the Bytetrack model fails to detect a target within five consecutive frames, the tracking model advances the target's disappearance by 10 frames and performs optical flow tracking until the target is found within five frames. The Bytetrack model is then used to track the target. This compensates for poor tracking performance caused by missed target detection, improves target recall, and enhances tracking effectiveness, particularly in crowded passenger conditions where target occlusion is common, enabling high tracking accuracy.
[0083] In the process of target tracking, the recall rate of tracking is increased by adding the optical flow method. Targets missed in target detection can also be captured well, thereby improving the accuracy of human movement direction.
[0084] S140: Determine a target angle according to the tracking trajectory result and the face orientation angle.
[0085] In this embodiment, the target angle refers to a specific angle of the face orientation determined by combining the human body motion trajectory with the predicted face orientation angle.
[0086] In one embodiment, see Figure 4 , the above-mentioned step S140 may include steps S141 to S142.
[0087] S141: Determine a tracking orientation angle according to the tracking trajectory result.
[0088] In this embodiment, the tracking orientation angle refers to the angle of the orientation determined by the trajectory of the human body.
[0089] Specifically, the movement trajectory of each passenger is recorded each time. Here, the trajectory is the latest 50 frames. The direction of the trajectory movement is from the starting point of the trajectory to the end point of the trajectory. The tracking direction angle is set to ω tracking .
[0090] S142: Determine a target angle according to the tracking orientation angle and the face orientation angle.
[0091] Specifically, the face orientation angle is ω FaceOrientation The face represented by the target angle is the final prediction Among them, γ is used to achieve the purpose of angle judgment weight, which is set to 0.6 here.
[0092] S150. Determine whether the corresponding passenger is a person traveling against traffic based on the target angle.
[0093] In one embodiment, see Figure 5 , the above-mentioned step S150 may include steps S151 to S154.
[0094] S151, calculating the difference between the target angle and a preset retrograde face angle;
[0095] S152, determining whether the difference exceeds a set threshold;
[0096] S153: If the difference exceeds a set threshold, determining that the corresponding passenger is a person traveling against traffic;
[0097] S154: If the difference does not exceed the set threshold, it is determined that the corresponding passenger is not a person traveling against traffic.
[0098] By τ = ω p -μ 逆行 Calculate the target angle and the preset reverse face angle μ 逆行 The difference between the two angles is used to determine whether the passenger is traveling in the wrong direction. If the wrong direction angle, i.e., the difference τ, is less than the set threshold, an alarm is issued.
[0099] S160: If the corresponding passenger is a person walking against traffic, a wrong-travel warning message is generated and sent to the terminal.
[0100] If the corresponding passenger is not a person traveling against traffic, the process proceeds to the end step.
[0101] The above-mentioned method for detecting people walking against the flow obtains the image taken by the camera and cuts it, so as to detect the target frame of the human face and predict the face direction in the generated target detection model of the image to be detected, and combines the tracking model to track the target. The face direction angle is determined according to the tracking trajectory results. When the corresponding passenger is a person walking against the flow, an alarm is issued to improve the accuracy of detecting people walking against the flow, and make up for the situation where deep learning detection targets are missed due to dense crowds.
[0102] Figure 6 FIG is a schematic block diagram of a wrong-way person detection device 300 provided by an embodiment of the present invention. Figure 6 As shown, corresponding to the above-mentioned wrong-way person detection method, the present invention also provides a wrong-way person detection device 300. The wrong-way person detection device 300 includes a unit for executing the above-mentioned wrong-way person detection method, and the device can be configured in a server. Figure 6 The wrong-walking person detection device 300 includes a sampling unit 301, a target detection unit 302, a target tracking unit 303, an angle determination unit 304, a judgment unit 305 and an alarm unit 306.
[0103] The sampling unit 301 is used to obtain the video captured by the camera and process the video to obtain the picture to be detected; the target detection unit 302 is used to input the picture to be detected into the target detection model to detect the face target frame and predict the face direction angle to obtain the detection result; the target tracking unit 303 is used to input the detection result into the tracking model to track the target to obtain the tracking trajectory result; the angle determination unit 304 is used to determine the target angle according to the tracking trajectory result and the face direction angle; the judgment unit 305 is used to judge whether the corresponding passenger is a person walking against the traffic according to the target angle; the alarm unit 306 is used to generate a reverse traffic alarm message if the corresponding passenger is a person walking against the traffic, and send the reverse traffic alarm message to the terminal.
[0104] In one embodiment, if Figure 7 As shown, the target detection unit 302 includes a target box detection subunit 3021, a feature mapping subunit 3022, a splicing subunit 3023 and a direction prediction subunit 3024.
[0105] The target frame detection subunit 3021 is used to input the image to be detected into the target detection model to detect the facial target frame; the feature mapping subunit 3022 is used to perform feature mapping from the N2 layer and the N3 layer of the YOLOv5 model based on the ROI Align mechanism and the SPP method according to the facial target frame to obtain facial features; the splicing subunit 3023 is used to splice the original features according to the facial features to obtain fused features; the orientation prediction subunit 3024 is used to predict the facial orientation angle according to the fused features through the global average pooling, fully connected layer and face orientation prediction branch of the YOLOv5 model, and integrate the predicted facial orientation angle with the facial target frame to obtain a detection result.
[0106] In one embodiment, the splicing sub-unit 3023 is used to splice original features based on facial features to obtain fused features, and when the similarity between the fused features corresponding to passengers within a certain threshold value at the edge of the picture within the video shooting range and the fused features corresponding to the images to be detected by other adjacent cameras is less than the similarity set threshold value, the two fused features are marked as the same face index.
[0107] In one embodiment, if Figure 8 As shown, the angle determining unit 304 includes a first determining subunit 3041 and a second determining subunit 3042 .
[0108] The first determining subunit 3041 is used to determine the tracking direction angle according to the tracking trajectory result; the second determining subunit 3042 is used to determine the target angle according to the tracking direction angle and the face direction angle.
[0109] In one embodiment, if Figure 9 As shown, the judgment unit 305 includes a difference calculation subunit 3051 , a difference judgment subunit 3052 , a third determination subunit 3053 and a fourth determination subunit 3054 .
[0110] The difference calculation subunit 3051 is used to calculate the difference between the target angle and the preset wrong-traveling face angle; the difference judgment subunit 3052 is used to judge whether the difference exceeds the set threshold; the third determination subunit 3053 is used to determine that the corresponding passenger is a wrong-traveling person if the difference exceeds the set threshold; the fourth determination subunit 3054 is used to determine that the corresponding passenger is not a wrong-traveling person if the difference does not exceed the set threshold.
[0111] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned wrong-walking person detection device and each unit can refer to the corresponding description in the aforementioned method embodiment. For the convenience and brevity of description, it will not be repeated here.
[0112] The above-mentioned wrong-way person detection device 300 can be implemented in the form of a computer program. The computer program can be used in Figure 10 Runs on the computer equipment shown.
[0113] See also Figure 10 , Figure 10 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a server, wherein the server may be an independent server or a server cluster composed of multiple servers.
[0114] See Figure 10 The computer device 500 includes a processor 502 , a memory, and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0115] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, which, when executed, can enable the processor 502 to execute a method for detecting a person walking against traffic.
[0116] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500.
[0117] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a method for detecting people walking against traffic.
[0118] The network interface 505 is used to communicate with other devices through the network. Figure 10 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0119] The processor 502 is configured to execute a computer program 5032 stored in the memory to implement the following steps:
[0120] The video captured by the camera is obtained and processed to obtain a picture to be detected; the picture to be detected is input into the target detection model to detect the target frame of the face and predict the face orientation angle to obtain a detection result; the detection result is input into the tracking model to track the target to obtain a tracking trajectory result; the target angle is determined according to the tracking trajectory result and the face orientation angle; according to the target angle, it is determined whether the corresponding passenger is a person walking against the traffic; if the corresponding passenger is a person walking against the traffic, a reverse traffic warning message is generated and sent to the terminal.
[0121] The target detection model is formed by adding a face orientation prediction branch to the YOLOv5 model.
[0122] The tracking model is formed by adding a sparse optical flow method to the Bytetrack model. When the tracking model uses the Bytetrack model to track a target and the target is not detected within a specified number of consecutive frames, the optical flow tracking of the target is advanced by several frames from the time it disappears. If the target is found within the specified number of frames, the Bytetrack model is continued to be used for target tracking.
[0123] In one embodiment, when the processor 502 implements the step of inputting the image to be detected into the target detection model to detect the face target frame and predict the face orientation angle to obtain the detection result, the processor 502 specifically implements the following steps:
[0124] The image to be detected is input into the target detection model to detect the facial target frame; feature mapping is performed from the N2 layer and N3 layer of the YOLOv5 model based on the ROI Align mechanism and the SPP method to obtain facial features; original features are spliced according to the facial features to obtain fused features; based on the fused features, the face orientation angle is predicted through the global average pooling, fully connected layer and face orientation prediction branch of the YOLOv5 model, and the predicted face orientation angle is integrated with the facial target frame to obtain a detection result.
[0125] In one embodiment, when the processor 502 implements the step of determining the target angle according to the tracking trajectory result and the face orientation angle, the processor 502 specifically implements the following steps:
[0126] A tracking orientation angle is determined according to the tracking trajectory result; and a target angle is determined according to the tracking orientation angle and the face orientation angle.
[0127] In one embodiment, when the processor 502 implements the step of determining whether the corresponding passenger is a wrong-way traveler according to the target angle, the processor 502 specifically implements the following steps:
[0128] Calculate the difference between the target angle and the preset wrong-traveling face angle; determine whether the difference exceeds a set threshold; if the difference exceeds the set threshold, determine that the corresponding passenger is a wrong-traveling person; if the difference does not exceed the set threshold, determine that the corresponding passenger is not a wrong-traveling person.
[0129] In one embodiment, when the processor 502 implements the step of splicing original features according to facial features to obtain fused features, it specifically implements the following steps:
[0130] The original features are spliced according to the facial features to obtain the fused features. If the similarity between the fused features corresponding to the passengers within a certain threshold of the edge of the picture within the video shooting range and the fused features corresponding to the images to be detected by other adjacent cameras is less than the similarity set threshold, the two fused features are marked as the same face index.
[0131] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0132] Those skilled in the art will appreciate that all or part of the steps in the method of the above-described embodiment can be implemented by instructing the relevant hardware through a computer program. The computer program includes program instructions, which can be stored in a storage medium that is computer-readable. The program instructions are executed by at least one processor in the computer system to implement the steps in the method of the above-described embodiment.
[0133] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein when the computer program is executed by a processor, the processor performs the following steps:
[0134] The video captured by the camera is obtained and processed to obtain a picture to be detected; the picture to be detected is input into the target detection model to detect the target frame of the face and predict the face orientation angle to obtain a detection result; the detection result is input into the tracking model to track the target to obtain a tracking trajectory result; the target angle is determined according to the tracking trajectory result and the face orientation angle; according to the target angle, it is determined whether the corresponding passenger is a person walking against the traffic; if the corresponding passenger is a person walking against the traffic, a reverse traffic warning message is generated and sent to the terminal.
[0135] The target detection model is formed by adding a face orientation prediction branch to the YOLOv5 model.
[0136] The tracking model is formed by adding a sparse optical flow method to the Bytetrack model. When the tracking model uses the Bytetrack model to track a target and the target is not detected within a specified number of consecutive frames, the optical flow tracking of the target is advanced by several frames from the time it disappears. If the target is found within the specified number of frames, the Bytetrack model is continued to be used for target tracking.
[0137] In one embodiment, when the processor executes the computer program to implement the step of inputting the image to be detected into the target detection model to detect the face target frame and predict the face orientation angle to obtain the detection result, the processor specifically implements the following steps:
[0138] The image to be detected is input into the target detection model to detect the facial target frame; feature mapping is performed from the N2 layer and N3 layer of the YOLOv5 model based on the ROI Align mechanism and the SPP method to obtain facial features; original features are spliced according to the facial features to obtain fused features; based on the fused features, the face orientation angle is predicted through the global average pooling, fully connected layer and face orientation prediction branch of the YOLOv5 model, and the predicted face orientation angle is integrated with the facial target frame to obtain a detection result.
[0139] In one embodiment, when the processor executes the computer program to implement the step of determining the target angle based on the tracking trajectory result and the face orientation angle, the processor specifically implements the following steps:
[0140] A tracking orientation angle is determined according to the tracking trajectory result; and a target angle is determined according to the tracking orientation angle and the face orientation angle.
[0141] In one embodiment, when the processor executes the computer program to implement the step of determining whether the corresponding passenger is a person traveling against traffic based on the target angle, the processor specifically implements the following steps:
[0142] Calculate the difference between the target angle and the preset wrong-traveling face angle; determine whether the difference exceeds a set threshold; if the difference exceeds the set threshold, determine that the corresponding passenger is a wrong-traveling person; if the difference does not exceed the set threshold, determine that the corresponding passenger is not a wrong-traveling person.
[0143] In one embodiment, when the processor executes the computer program to implement the step of splicing original features according to facial features to obtain fused features, the processor specifically implements the following steps:
[0144] The original features are spliced according to the facial features to obtain the fused features. If the similarity between the fused features corresponding to the passengers within a certain threshold of the edge of the picture within the video shooting range and the fused features corresponding to the images to be detected from other adjacent cameras is less than the similarity set threshold, the two fused features are marked as the same face index.
[0145] The storage medium may be any computer-readable storage medium that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk.
[0146] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0147] In the several embodiments provided herein, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the various units is merely a logical functional division, and actual implementation may employ other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not implemented.
[0148] The steps in the methods of the embodiments of the present invention may be adjusted in order, combined, or deleted as needed. The units in the devices of the embodiments of the present invention may be combined, divided, or deleted as needed. Furthermore, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit.
[0149] If this integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the existing technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, terminal, or network device, etc.) to execute all or part of the steps of the method described in various embodiments of the present invention.
[0150] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and such modifications or substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.
Claims
1. A method for detecting people walking against traffic, characterized in that: include: Obtain the video captured by the camera and process the video to obtain the image to be detected; Input the image to be detected into the target detection model to detect the human face target frame and predict the face orientation angle to obtain the detection result; Inputting the detection results into a tracking model to perform target tracking to obtain a tracking trajectory result; Determine the target angle according to the tracking trajectory result and the face orientation angle; Determine whether the corresponding passenger is a person traveling against traffic according to the target angle; If the corresponding passenger is a person walking against traffic, a wrong-travel warning message is generated and sent to the terminal; The target detection model is formed by adding a face orientation prediction branch to the YOLOv5 model; Inputting the image to be detected into the target detection model to detect the face target frame and predict the face orientation angle to obtain the detection result includes: Input the image to be detected into the target detection model to detect the target frame of the human face; Perform feature mapping from the N2 layer and the N3 layer of the YOLOv5 model based on the ROI Align mechanism and the SPP method according to the facial target frame to obtain facial features; The original features are spliced according to the facial features to obtain the fusion features; Predicting the face orientation angle through the global average pooling, fully connected layer, and face orientation prediction branch of the YOLOv5 model based on the fusion features, and integrating the predicted face orientation angle with the face target frame to obtain a detection result; The tracking model is formed by adding a sparse optical flow method to the Bytetrack model. When the tracking model uses the Bytetrack model to track a target and the target is not detected within a specified number of consecutive frames, the optical flow tracking of the target is advanced by several frames from the time it disappears. If the target is found within the specified number of frames, the Bytetrack model is continued to be used for target tracking.
2. The method for detecting people walking against traffic according to claim 1, wherein: The determining the target angle according to the tracking trajectory result and the face orientation angle includes: Determining a tracking orientation angle according to the tracking trajectory result; The target angle is determined according to the tracking orientation angle and the face orientation angle.
3. The method for detecting people walking against traffic according to claim 2, wherein: The determining, based on the target angle, whether the corresponding passenger is a person traveling against traffic includes: Calculating the difference between the target angle and a preset retrograde face angle; Determining whether the difference exceeds a set threshold; If the difference exceeds a set threshold, it is determined that the corresponding passenger is a person traveling against traffic; If the difference does not exceed the set threshold, it is determined that the corresponding passenger is not a person traveling against traffic.
4. The method for detecting people walking against traffic according to claim 1, wherein: The process of combining original features according to facial features to obtain fused features further includes: The original features are spliced according to the facial features to obtain the fused features. If the similarity between the fused features corresponding to the passengers within a certain threshold of the edge of the picture within the video shooting range and the fused features corresponding to the images to be detected by other adjacent cameras is less than the similarity set threshold, the two fused features are marked as the same face index.
5. A device for detecting people walking against traffic, the device using the method for detecting people walking against traffic according to any one of claims 1 to 4, characterized in that: include: The sampling unit is used to obtain the video captured by the camera and process the video to obtain the image to be detected; The target detection unit is used to input the image to be detected into the target detection model to detect the target frame of the human face and predict the face direction angle to obtain a detection result; A target tracking unit, configured to input the detection result into a tracking model to perform target tracking to obtain a tracking trajectory result; An angle determination unit, configured to determine a target angle based on the tracking trajectory result and the face orientation angle; a judgment unit, configured to judge whether the corresponding passenger is a person traveling against traffic according to the target angle; The alarm unit is used to generate a wrong-travel alarm message if the corresponding passenger is a wrong-travel person, and send the wrong-travel alarm message to the terminal.
6. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 4 when executing the computer program.
7. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Multi-pedestrian cross-camera online tracking system
CN110852219A
Escalator passenger retrograde motion detection method based on deep learning
CN111144247A
Face image screening method and device, electronic equipment and storage medium
CN112507985A
Micropapilla detection system based on YOLOv5
CN113344849A