Traffic statistics method and apparatus

By using the aspect ratio of the body detection box to predict the head detection box in the pedestrian flow statistics, the problems of light and environmental influences are solved, and more accurate flow statistics are achieved.

CN116964645BActive Publication Date: 2026-01-02BOE TECHNOLOGY GROUP CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202280000256.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-23
Publication Date
2026-01-02
Estimated Expiration
2042-02-23

AI Technical Summary

Technical Problem

Existing technologies are easily affected by lighting or environmental factors in people flow statistics, leading to missed detection of faces or false detections due to body frame shaking, resulting in low accuracy.

Method used

Body detection is performed by acquiring images of the target location. After determining the body detection bounding box, the head detection bounding box is predicted based on the aspect ratio of the body detection bounding box. Pseudo-head detection bounding boxes are used for traffic statistics to avoid false detections and missed detections of the body detection bounding box.

Benefits of technology

It improves the accuracy of pedestrian flow statistics, reduces the impact of light and environment on detection, and ensures the accuracy and reliability of flow data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116964645B_ABST
    Figure CN116964645B_ABST
Patent Text Reader

Abstract

The application provides a traffic statistics method and device, the method comprises the following steps: acquiring a first image of a target place; performing body detection on the first image to obtain a body detection frame of each target object in the first image; wherein the body detection frame indicates a body region of the target object; for each target object, determining a head detection frame of the target object according to the body detection frame of the target object; wherein the head detection frame indicates a head region of the target object; and obtaining a traffic statistics result of the target place according to the head detection frame of each target object, so as to realize accurate statistics of traffic data and improve the accuracy of traffic statistics.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, and in particular to a traffic statistics method and device. BACKGROUND

[0002] With the development of technology, image recognition technology is widely applied in various fields (for example, the field of people flow statistics).

[0003] At present, when the people flow of an in-out target place is counted, image recognition is performed on the collected related images, and a face frame or a body frame in the images is determined for traffic statistics using the face frame or the body frame.

[0004] However, when traffic statistics is performed based on the face frame, it is easy to be affected by light or environment, causing missed detection of the face, and thus leading to low accuracy of traffic statistics; when traffic statistics is performed based on the body frame, it is easy to cause the problem of false detection due to shaking of the body frame, thus leading to low accuracy of traffic statistics. SUMMARY

[0005] Therefore, one of the purposes of the present application is to provide a traffic statistics method and device.

[0006] According to a first aspect of the present application, a traffic statistics method is provided, and the method comprises:

[0007] obtaining a first image of a target place;

[0008] performing body detection on the first image to obtain a body detection frame of each target object in the first image; wherein the body detection frame indicates a body region of the target object;

[0009] for each target object, determining a head detection frame of the target object according to the body detection frame of the target object; wherein the head detection frame indicates a head region of the target object;

[0010] obtaining a traffic statistics result of the target place according to the head detection frame of each target object.

[0011] Optionally, the determining of the head detection frame of the target object according to the body detection frame of the target object comprises:

[0012] obtaining a width and a height of the body detection frame;

[0013] performing a reduction operation on the body detection frame according to the width and the height to obtain the head detection frame.

[0014] Optionally, the target object is a person.

[0015] The head detection frame is obtained by performing a reducing operation on the body detection frame according to the width and the height, and the method comprises the following steps:

[0016] A width-height ratio of the body detection frame is determined according to the width and the height of the body detection frame;

[0017] A target preset ratio range to which the width-height ratio of the body detection frame belongs is obtained; wherein the preset ratio range is determined based on a human body posture of a target object;

[0018] A height reducing ratio corresponding to the target preset ratio range is obtained, and a reducing operation is performed on the body detection frame in a height direction based on the height reducing ratio.

[0019] Optionally, the method further comprises:

[0020] A reducing operation is performed on the body detection frame in a width direction based on a preset width reducing ratio;

[0021] Alternatively,

[0022] A width reducing ratio corresponding to the target preset ratio range is obtained, and a reducing operation is performed on the body detection frame in a width direction based on the width reducing ratio.

[0023] Optionally, the traffic statistical result of the target site is obtained according to the head detection frame of each target object, and the method comprises the following steps:

[0024] For each target object, a behavior state of the target object is determined according to a positional relationship between the head detection frame of the target object and a set region in the first image of the target site, wherein the behavior state of the target object indicates whether the target object enters or exits the target site;

[0025] The traffic statistical result of the target site is determined according to the behavior state of each target object.

[0026] Optionally, the behavior state of the target object is determined according to the positional relationship between the head detection frame of the target object and the set region in the first image of the target site, and the method comprises the following steps:

[0027] A position determination result corresponding to the target object is determined according to the positional relationship between the head detection frame of the target object and the set region in the first image of the target site; wherein the position determination result indicates whether the target object enters the set region;

[0028] The behavior state of the target object is determined according to the position determination result.

[0029] Optionally, the set region includes an entering region and a leaving region.

[0030] The behavior state of the target object is determined according to the position determination result, and the behavior state of the target object includes:

[0031] In a case where the position determination results of two adjacent positions indicate that the target object passes through the entering region and the leaving region in sequence, it is determined that the behavior state indicates entering the target site; and / or,

[0032] In a case where the position determination results of two adjacent positions indicate that the target object passes through the leaving region and the entering region in sequence, it is determined that the behavior state indicates leaving the target site.

[0033] Optionally, the first image is one frame in an image sequence; and the position relationship indicates whether the target object is in the set region.

[0034] The position determination result corresponding to the target object is determined according to a position relationship between the head detection frame of the target object and the set region in the first image of the target site, and the position relationship includes:

[0035] In response to the position relationship in more than a first set number of continuous frames indicating that the target object is in the set region, it is determined that the position determination result corresponding to the target object indicates that the target object enters the set region.

[0036] Optionally, the boundary frame of the set region includes an outer boundary frame and an inner boundary frame.

[0037] The method further includes:

[0038] In a case where the head detection frame of the target object is within the inner boundary frame of the set region, it is determined that the position relationship between the head detection frame and the set region indicates that the target object is in the set region.

[0039] In a case where the head detection frame of the target object is between the inner boundary frame and the outer boundary frame of the set region, the position relationship between the head detection frame and the set region is determined according to a second image; wherein the second image is an image before the first image.

[0040] In a case where the head detection frame of the target object is outside the outer boundary frame of the set region, it is determined that the position relationship between the head detection frame and the set region indicates that the target object is not in the set region.

[0041] Optionally, the position relationship between the head detection frame and the set region is determined according to the second image, and the position relationship includes:

[0042] in a case where the positional relationship between the head detection frame of the target object and the set region in the second image indicates that the target object is in the set region, determining that the positional relationship between the head detection frame of the target object and the set region in the first image indicates that the target object is in the set region;

[0043] in a case where the positional relationship between the head detection frame of the target object and the set region in the second image indicates that the target object is not in the set region, determining that the positional relationship between the head detection frame of the target object and the set region in the first image indicates that the target object is not in the set region.

[0044] Optionally, the method further comprises:

[0045] obtaining a set region setting request;

[0046] performing corresponding setting processing on the set region according to the set region setting request; wherein the setting processing comprises at least one of set region opening processing, set region closing processing, set region corresponding opening time period setting processing, interval setting processing between a boundary frame and an inner boundary frame.

[0047] Optionally, the set region corresponding boundary frame comprises a first boundary line and a second boundary line; wherein the first boundary line is a side of the set region that the target object passes through when entering the target site, which is preset based on the direction of entering the target site; the second boundary line is a side of the set region that the target object passes through when leaving the target site, which is preset based on the direction of leaving the target site; the first boundary line and the second boundary line are opposite to each other.

[0048] the determining the behavior state of the target object according to the position determination result comprises:

[0049] in response to the position determination results of the two adjacent positions being different, obtaining a boundary line that the target object has most recently passed through; wherein the boundary line is the first boundary line or the second boundary line;

[0050] determining the behavior state of the target object according to the boundary line and the position determination results of the two adjacent positions.

[0051] Optionally, the determining the behavior state of the target object according to the boundary line and the position determination results of the two adjacent positions comprises:

[0052] in a case where the boundary line is the first boundary line, and the position determination results of the two adjacent positions indicate that the target object enters the set region and does not enter the set region in sequence, determining that the behavior state of the target object is entering the target site;

[0053] and / or,

[0054] In a case where the boundary line is a second boundary line and the position determination results of the two adjacent objects indicate that the target object enters a set region and does not enter the set region in sequence, the behavior state of the target object is determined as leaving the target site.

[0055] Optionally, the method further comprises:

[0056] obtaining feature information of each target object on the first image;

[0057] determining an object identifier corresponding to the target object according to the feature information;

[0058] displaying the object identifier corresponding to the target object on the first image.

[0059] Optionally, the determining an object identifier corresponding to the target object according to the feature information comprises:

[0060] in a case where the target object is a first appearance object, assigning an object identifier other than the object identifiers contained in the first image to the target object, and storing a correspondence between the feature information of the target object and the object identifier in a preset table;

[0061] in a case where the target object is not a first appearance object, obtaining an object identifier corresponding to the target object from the preset table according to the feature information of the target object.

[0062] Optionally, the method further comprises:

[0063] in a case where the target object to which an object identifier has been assigned is not detected in more than a second set number of continuous frames, deleting the correspondence between the target object and the object identifier from the preset table.

[0064] According to a second aspect of the present application, a traffic statistics device is provided, comprising:

[0065] an image acquisition module configured to acquire a first image of a target site;

[0066] an image processing module configured to perform body detection on the first image to obtain a body detection frame of each target object in the first image; wherein the body detection frame indicates a body region of the target object;

[0067] a head determination module configured to, for each target object, determine a head detection frame of the target object according to the body detection frame of the target object; wherein the head detection frame indicates a head region of the target object;

[0068] a flow statistics module configured to obtain a flow statistics result of the target place according to the head detection frame of each target object.

[0069] Optionally, the head determination module is specifically configured to:

[0070] obtain a width and a height of the body detection frame;

[0071] perform a reduction operation on the body detection frame according to the width and the height to obtain the head detection frame.

[0072] Optionally, the target object is a human being.

[0073] The head determination module is further specifically configured to:

[0074] determine an aspect ratio of the body detection frame according to the width and the height of the body detection frame;

[0075] obtain a target preset ratio range to which the aspect ratio of the body detection frame belongs; wherein the preset ratio range is determined based on a human body posture of a target object;

[0076] obtain a height reduction ratio corresponding to the target preset ratio range, and perform a reduction operation on the body detection frame in a height direction based on the height reduction ratio.

[0077] Optionally, the head determination module is specifically configured to:

[0078] perform a reduction operation on the body detection frame in a width direction based on a preset width reduction ratio;

[0079] Alternatively,

[0080] obtain a width reduction ratio corresponding to the target preset ratio range, and perform a reduction operation on the body detection frame in the width direction based on the width reduction ratio.

[0081] Optionally, the flow statistics module is specifically configured to:

[0082] for each target object, determine a behavior state of the target object according to a positional relationship between the head detection frame of the target object and a set region in the first image of the target place, wherein the behavior state of the target object indicates whether the target object enters or exits the target place;

[0083] determine a flow statistics result of the target place according to the behavior state of each target object.

[0084] Optionally, the flow statistics module is further specifically configured to:

[0085] determine a position determination result corresponding to the target object according to a position relationship between the head bounding box of the target object and a set region in the first image of the target site, wherein the position determination result indicates whether the target object enters the set region;

[0086] determine a behavior state of the target object according to the position determination result.

[0087] Optionally, the set region includes an entering region and a leaving region.

[0088] The traffic counting module is further configured to:

[0089] in a case where the two adjacent position determination results successively indicate that the target object passes through the entering region and the leaving region, determine that the behavior state indicates entering the target site; and / or,

[0090] in a case where the two adjacent position determination results successively indicate that the target object passes through the leaving region and the entering region, determine that the behavior state indicates leaving the target site.

[0091] Optionally, the first image is one frame in an image sequence; and the position relationship indicates whether the target object is in the set region.

[0092] The traffic counting module is further configured to:

[0093] in response to the position relationship in more than a first set number of continuous frames indicating that the target object is in the set region, determine that the position determination result corresponding to the target object indicates that the target object enters the set region.

[0094] Optionally, the boundary box of the set region includes an outer boundary box and an inner boundary box.

[0095] The traffic counting module is further configured to:

[0096] in a case where the head bounding box of the target object is within the inner boundary box of the set region, determine that the position relationship between the head bounding box and the set region indicates that the target object is in the set region.

[0097] in a case where the head bounding box of the target object is between the inner boundary box and the outer boundary box of the set region, determine the position relationship between the head bounding box and the set region according to a second image; wherein the second image is an image before the first image.

[0098] in a case where the head bounding box of the target object is outside the outer boundary box of the set region, determine that the position relationship between the head bounding box and the set region indicates that the target object is not in the set region.

[0099] Optionally, the traffic statistics module is further configured to:

[0100] in a case where the positional relationship between the head bounding box of the target object and the set region in the second image indicates that the target object is in the set region, determine that the positional relationship between the head bounding box of the target object and the set region in the first image indicates that the target object is in the set region;

[0101] in a case where the positional relationship between the head bounding box of the target object and the set region in the second image indicates that the target object is not in the set region, determine that the positional relationship between the head bounding box of the target object and the set region in the first image indicates that the target object is not in the set region.

[0102] Optionally, the apparatus further comprises a region setting module;

[0103] The region setting module is specifically configured to:

[0104] obtain a set region setting request;

[0105] perform corresponding setting processing on the set region according to the set region setting request; wherein the setting processing comprises at least one of set region opening processing, set region closing processing, set region corresponding opening time period setting processing, interval setting processing between a boundary box and an inner boundary box.

[0106] Optionally, the set region corresponding boundary box comprises a first boundary line and a second boundary line; wherein the first boundary line is a side of the set region that a target place passes through, which is pre-set based on a direction of entering the target place; the second boundary line is a side of the set region that the target place passes through, which is pre-set based on a direction of leaving the target place; the first boundary line and the second boundary line are opposite to each other.

[0107] The traffic statistics module is further specifically configured to:

[0108] in response to the position determination results of the two adjacent positions being different, obtain a latest boundary line that the target object passes through; wherein the boundary line is the first boundary line or the second boundary line;

[0109] determine a behavior state of the target object according to the boundary line and the position determination results of the two adjacent positions.

[0110] Optionally, the traffic statistics module is further specifically configured to:

[0111] In a case where the boundary line is the first boundary line and the position determination results of the two adjacent objects indicate that the target object enters the set region and does not enter the set region in sequence, the behavior state of the target object is determined as entering the target site.

[0112] and / or,

[0113] In a case where the boundary line is the second boundary line and the position determination results of the two adjacent objects indicate that the target object enters the set region and does not enter the set region in sequence, the behavior state of the target object is determined as leaving the target site.

[0114] Optionally, the apparatus further includes an object identification determination module.

[0115] The object identification determination module is specifically configured to:

[0116] Obtain feature information of each target object on the first image;

[0117] Determine an object identification corresponding to the target object according to the feature information;

[0118] Display the object identification corresponding to the target object on the first image.

[0119] Optionally, the object identification determination module is further configured to:

[0120] In a case where the target object is a first appearance object, assign an object identification other than object identifications contained in the first image to the target object, and store a correspondence between the feature information of the target object and the object identification in a preset table;

[0121] In a case where the target object is not a first appearance object, obtain an object identification corresponding to the target object from the preset table according to the feature information of the target object.

[0122] Optionally, the object identification determination module is further configured to:

[0123] For a target object to which an object identification has been assigned, in a case where the target object is not detected in more than a second set number of continuous frames, delete the correspondence between the target object and the object identification from the preset table.

[0124] According to a third aspect of the present application, a computer device is provided, including:

[0125] A processor;

[0126] A memory for storing processor-executable instructions;

[0127] The processor is configured to:

[0128] obtaining a first image of a target place;

[0129] performing body detection on the first image to obtain a body detection frame of a target object; wherein the body detection frame indicates a body region of the target object;

[0130] determining a head detection frame of the target object according to the body detection frame; wherein the head detection frame indicates a head region of the target object;

[0131] obtaining a flow statistical result of the target place according to the head detection frame.

[0132] According to a fourth aspect of the present application, a computer readable storage medium is provided, and the computer readable storage medium stores computer execution instructions. When a processor executes the computer execution instructions, the flow statistical method according to the first aspect and various possible designs of the first aspect is implemented.

[0133] According to a fifth aspect of the present application, a computer program product is provided, and the computer program product includes a computer program. When a processor executes the computer program, the flow statistical method according to the first aspect and various possible designs of the first aspect is implemented.

[0134] The technical solutions provided in the present application can include the following beneficial effects:

[0135] In the present application, when the flow of target objects in a target place is counted, a first image of the target place is obtained, and body detection is performed on the first image to determine the body detection frame of each target object in the first image. The body frame represents the body region of the target object. The head detection frame of the target object is predicted according to the body detection frame of the target object, so as to count the number of target objects entering and / or leaving the target place by using the predicted head detection frame of the target object, i.e., the pseudo head detection frame, to realize the flow statistical of the target place. Since the flow is counted by using the pseudo head detection frame, the false detection caused by the relatively large area of the body detection frame and the shaking of the body detection frame can be avoided when the flow is counted based on the body detection frame. At the same time, the actual head region of the target object is not used in the present application, but the flow is counted by using the pseudo head detection frame. Since the body region of the target object has a relatively large area, the body region of the target object is less affected by light or environment, and is easy to be detected. Therefore, the missing detection of the head of the target object can be effectively avoided, so as to realize the accurate statistical of the flow data, and improve the accuracy of the flow statistical. BRIEF DESCRIPTION OF DRAWINGS

[0136] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor based on these drawings.

[0137] Figure 1 is a flow chart of a traffic statistics method according to an exemplary embodiment of the present application.

[0138] Figure 2 is a schematic diagram of a detection frame according to an exemplary embodiment of the present application.

[0139] Figure 3 is a flow chart of another traffic statistics method according to an exemplary embodiment of the present application.

[0140] Figure 4 is a schematic diagram of another detection frame according to an exemplary embodiment of the present application.

[0141] Figure 5 is a schematic diagram of setting a region according to an exemplary embodiment of the present application.

[0142] Figure 6 is a schematic diagram of another setting a region according to an exemplary embodiment of the present application.

[0143] Figure 7 is a schematic diagram of a traffic statistics process according to an exemplary embodiment of the present application.

[0144] Figure 8 is a schematic diagram of another setting a region according to an exemplary embodiment of the present application.

[0145] Figure 9 is a hardware structure diagram of a computer device in which a traffic statistics device of the present application is located.

[0146] Figure 10 is a block diagram of a traffic statistics device according to an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0147] The technical solutions in the embodiments of the present application will be described clearly and completely in the following description with reference to the drawings of the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0148] As Figure 1As shown, Figure 1 is a flowchart of a traffic counting method according to an exemplary embodiment of the present application, comprising the following steps:

[0149] S101, acquiring a first image of a target place.

[0150] In this embodiment, when traffic counting of a target place is needed, an image containing a specific position (for example, a position at an entrance, an exit, a doorway, etc.) of the target place is acquired as a first image for determining traffic data of target objects of the target place by using the first image.

[0151] Wherein, the camera device photographs the specific position of the target place to obtain a corresponding video. When it is needed to determine the traffic of the target place within a set time, a video photographed within the set time is acquired for determination by using images in the video. Specifically, the video is a sequence of images, and the first image is one frame of image in the sequence of images.

[0152] Optionally, a counting time can also be set, that is, a sequence of images photographed within the set time is acquired for counting traffic results of target objects of the target place within the set time by using the sequence of images.

[0153] Optionally, the target object is a person, and of course, it can also be other movable objects with a head, that is, a face, which is not limited by the present application. For the convenience of description, the person is taken as the target object in the following description.

[0154] S102, performing body detection on the first image to obtain a body detection frame of each target object in the first image. Wherein, the body detection frame indicates a body region of the target object.

[0155] In this embodiment, the first image is subjected to body detection to determine a body region of each target object in the first image, so as to obtain a body detection frame of each target object, and the body region indicates the entire body tissue of the target object.

[0156] Optionally, a target detection model is used to perform body detection on the first image to obtain a body detection frame of each target object in the first image (such as the body detection frame 10 shown in the figure). Figure 2 Wherein, the target detection model is a trained machine learning model, which can accurately determine the body part of the target object, so as to obtain the body detection frame of the target object.

[0157] Specifically, the first image is input into the target detection model, so that the target detection model performs body detection on the first image, and outputs a processed first image, which is an image with a body detection frame drawn.

[0158] Optionally, the target detection model comprises a machine learning model such as yolov5, SSD, YOLOX, etc.

[0159] S103, for each target object, determining a head detection box of the target object according to the body detection box of the target object. The head detection box indicates the head region of the target object.

[0160] In this embodiment, for each target object on the first image, the head region of the target object is predicted based on the body detection box corresponding to the target object, and the corresponding head detection box (such as the head detection box 20 shown in FIG. 2) is drawn, to obtain the pseudo head detection box corresponding to the target object. Figure 2

[0161] The head region predicted based on the body detection box can not be the actual head region of the target object. When a body detection box is obtained, a head detection box can be predicted.

[0162] S104, obtaining the flow statistics result of the target place according to the head detection box of each target object.

[0163] In this embodiment, after the head detection box of each target object in the first image is predicted, the target objects entering and / or leaving the target place are determined based on the head detection box of each target object, i.e., the pseudo head detection box, so as to determine the access flow data of the target objects, to obtain the flow statistics result of the target place, thereby realizing accurate statistics of the flow data of the target place.

[0164] In this embodiment, since the area of the body part of the target object is relatively large compared with the area of the head part, compared with directly detecting the actual head part of the target object, the influence of light, environment, etc. is smaller, and the probability of successful detection is higher, which can effectively avoid missed detection. At the same time, since the body detection box is not stable, after the target object performs some actions (such as stretching hands, raising arms, etc.), the body detection box will change, which will cause inaccurate detection, and further cause poor accuracy of flow statistics. Compared with directly performing flow statistics through the body detection box, performing flow statistics through the pseudo head detection box can ensure the accuracy of flow statistics.

[0165] ​In some implementations, both the body and head bounding boxes of a target object are detected simultaneously, and then an algorithm is used to associate the body and head bounding boxes. However, during the association process, mismatches between the body and head can occur due to mutual occlusion between target objects. For example, a head bounding box of one target object might be mismatched with the body bounding box of another target object located in front of it, leading to false detection of the target object and consequently lower accuracy in traffic statistics results. In this application, the head bounding box is predicted from the body bounding box, avoiding this type of mismatch and ensuring the accuracy of target object detection, thereby guaranteeing the accuracy of traffic statistics results.

[0166] As described above, when performing traffic statistics on target objects at a target location, a first image of the target location is acquired, and body detection is performed on the first image to determine the body detection boxes of each target object in the first image. These body boxes represent the body regions of the target objects. Based on the body detection boxes of each target object, head detection boxes of each target object are predicted. These predicted head detection boxes, i.e., pseudo-head detection boxes, are then used for traffic statistics to obtain the number of target objects entering and / or leaving the target location, thus achieving traffic statistics for the target location. Since this application uses pseudo-head detection boxes for traffic statistics, it avoids the false detections caused by the relatively large body detection box area, which is prone to jitter. Furthermore, since this application does not use the actual head region of the target object (i.e., the actual head detection box), but rather uses pseudo-head detection boxes for traffic statistics, the relatively large body region of the target object is less affected by light or environmental conditions and is easier to detect. This effectively avoids missing the heads of target objects, thereby achieving accurate traffic data statistics and improving the accuracy of traffic statistics.

[0167] like Figure 3 As shown, Figure 3 This is a flowchart illustrating another traffic statistics method according to an exemplary embodiment of this application. Based on the foregoing embodiments, this implementation describes a process for predicting the head region within a detected body detection frame. The process will be described in detail below with reference to a specific embodiment. Figure 3 As shown, the method includes the following steps:

[0168] S301, Obtain the first image of the target location.

[0169] S302. Perform body detection on the first image to obtain a body detection box for each target object in the first image. The body detection box indicates the body region of the target object.

[0170] S303, for each target object, obtain the width and height of the body detection box of the target object.

[0171] S304, perform a reduction operation on the body detection box according to the width and height, to obtain a head detection box.

[0172] In this embodiment, for each target object in the first image, the width and height of the body detection box of the target object are obtained. Based on the width and height of the body detection box of the target object, the body detection box of the target object is reduced to obtain a head detection box of the target object, to realize determination of the pseudo head detection box.

[0173] The width of the body detection box indicates the width of the target object, and the height of the body detection box indicates the height of the target object.

[0174] Optionally, when the body detection box of the target object is reduced according to the width and height of the body detection box of the target object to determine the pseudo head detection box of the target object, the aspect ratio of the body detection box is determined according to the width and height of the body detection box, and a target preset ratio range to which the aspect ratio of the body detection box belongs is obtained. The preset ratio range is determined based on the human posture of the target object. A height reduction ratio corresponding to the target preset ratio range is obtained, and the height of the body detection box is reduced in the height direction based on the height reduction ratio.

[0175] Specifically, for each target object in the first image, the ratio of the width and height of the body detection box of the target object is calculated to obtain the aspect ratio of the body detection box of the target object. The preset ratio range to which the aspect ratio of the body detection box belongs is searched, and the preset ratio range to which the aspect ratio belongs is taken as the target preset ratio range. The height reduction ratio corresponding to the target preset ratio range is searched, so that the height of the body detection box is reduced according to the height reduction ratio, to obtain the head detection box. For example, the height reduction ratio is 1 / 7, and the height of the head detection box obtained by reduction is 1 / 7 of the height of the body detection box.

[0176] The preset ratio range is determined based on the human posture. The human posture includes one or more of a standing posture, a non-standing posture, and a specific posture. Each human posture corresponds to a preset ratio range. When the human posture of a person is different, the height of the head part of the person occupies the whole body part, that is, the height reduction ratio is different. Therefore, each preset ratio range has a corresponding height reduction ratio, that is, each human posture corresponds to a height reduction ratio.

[0177] Specifically, when the target preset ratio range is the preset ratio range corresponding to the standing state, it indicates that the target object is in the standing state, and then the height reduction ratio corresponding to the standing state can be obtained from the related mapping table, so as to reduce the body bounding box of the target object in the height direction according to the height reduction ratio, and obtain the head bounding box of the target object.

[0178] The preset ratio range and the height reduction ratio corresponding to different postures of the human body can be set according to actual conditions. For example, the preset ratio range corresponding to the standing posture is between 0 and 1 / 4, and when a person is in a standing state, the head occupies 1 / 7 of the height of the human body, that is, the head-body ratio is 1 / 7, so the height reduction ratio corresponding to the standing posture can be 1 / 7; the preset ratio range corresponding to the non-standing posture (for example, the posture of squatting, etc.) is greater than 1 / 4 and less than 1, and the height reduction ratio corresponding to the non-standing posture is 1 / 3; the preset ratio range corresponding to the specific posture (for example, the posture of lying horizontally, etc.) is greater than or equal to 1, and since the height of the body is low when a person is in the specific posture, the height of the body bounding box can be directly used as the height of the head bounding box, and correspondingly, the height reduction ratio corresponding to the specific posture is 1. Figure 2 Figure 4 The preset ratio range corresponding to the specific posture (for example, the posture of lying horizontally, etc.) is greater than or equal to 1, and since the height of the body is low when a person is in the specific posture, the height of the body bounding box can be directly used as the height of the head bounding box, and correspondingly, the height reduction ratio corresponding to the specific posture is 1.

[0179] Optionally, when the head bounding box is determined, the width of the head bounding box can also be determined. Since the posture of the human body has little effect on the width of the human body, the body bounding box can be reduced in the width direction based on a preset width reduction ratio.

[0180] The preset width reduction ratio is obtained by research of relevant personnel, and the head bounding box obtained by reducing the body bounding box in the width direction according to the preset width reduction ratio has a high matching degree with the actual head region of the target object, avoiding false statistics caused by the head bounding box being too large or too small, and at the same time, since the reduction is directly according to the preset width reduction ratio, the speed of determining the head bounding box can be improved.

[0181] Optionally, the width reduction ratio can also be determined according to the width-height ratio of the body bounding box, and the body bounding box is reduced in the width direction according to the width reduction ratio. The process of determining the width reduction ratio based on the width-height ratio is similar to the process of determining the height reduction ratio based on the width-height ratio, and will not be described here.

[0182] ​In the embodiment, the pseudo face detection frame of the target object is determined by the aspect ratio of the body detection frame of the target object, so as to perform traffic statistics by using the pseudo face detection frame. Compared with the traffic statistics by using the actual face frame obtained by face detection, since the body feature is more obvious than the face feature, the target object can be avoided from being missed due to some reasons (for example, the target object is shielded from the head due to wearing a hat, a helmet, an umbrella, and the like, the light is relatively dark, and the like), and the pseudo face detection frame is determined based on the aspect ratio of the body detection frame, that is, is determined based on the human posture of the target object. Therefore, the position and size of the determined pseudo face detection frame are also accurate, so that the traffic statistics can be accurately performed by using the pseudo face detection frame, and the accuracy of the traffic statistics result of the target place is ensured.

[0183] S305, obtaining the traffic statistics result of the target place according to the head detection frame of each target object.

[0184] In the embodiment, for each target object in the first image, the behavior state of the target object is determined according to the positional relationship between the head detection frame of the target object and the set region in the first image of the target place, wherein the behavior state of the target object indicates whether the target object enters or leaves the target place. The traffic statistics result of the target place is determined according to the behavior state of each target object.

[0185] The traffic statistics result includes an entering traffic statistics result and / or a leaving traffic statistics result. The entering traffic statistics result indicates the number of target objects entering the target place, and the leaving traffic statistics result indicates the number of target objects leaving the target place.

[0186] In the embodiment, whether the target object enters or leaves the target place is determined based on the positional relationship between the head detection frame of the target object and the set region of the target place, so as to obtain the behavior state of the target object. The number of target objects entering the target place is obtained by the behavior state, so as to obtain the entering traffic statistics result of the target place, and / or the number of target objects leaving the target place is obtained by the behavior state, so as to obtain the leaving traffic statistics result of the target place.

[0187] Specifically, the entering traffic statistics result indicates the number of target objects entering the target place within a set time, and the leaving traffic statistics result indicates the number of target objects leaving the target place within a set time. Accordingly, when the entering traffic statistics result is determined, the number of target objects entering the target place indicated by the behavior state determined within the set time is obtained, so as to obtain the entering traffic statistics result. When the leaving traffic statistics result is determined, the number of target objects leaving the target place indicated by the behavior state determined within the set time is obtained, so as to obtain the leaving traffic statistics result.

[0188] Optionally, the behavior state of the target object is determined according to a positional relationship between the head bounding box of the target object and the set region in the first image of the target site, and the behavior state of the target object comprises:

[0189] According to the positional relationship between the head bounding box of the target object and the set region in the first image of the target site, a position determination result corresponding to the target object is determined. The position determination result indicates whether the target object enters the set region.

[0190] According to the position determination result, the behavior state of the target object is determined.

[0191] Specifically, when detecting the first image, the first image is taken as a current image, and a time corresponding to the first image, i.e., a time when the first image is captured, is taken as a current time. For each target object in the first image, according to the positional relationship between the target object and the set region in the first image, it is determined whether the target object enters the set region at the current time, so as to obtain a position determination result of the target object at the current time. Since the behavior state of the target object needs to be determined according to the continuous behavior of the target object, whether the target object enters or leaves the target site, therefore, based on the position determination results of the target object in multiple image frames, i.e., after obtaining the position determination result at the current time, the position determination results of other image frames are combined to determine the behavior state of the target object.

[0192] Optionally, the positional relationship indicates whether the target object is in the set region. Correspondingly, according to the positional relationship between the head bounding box of the target object and the set region in the first image of the target site, the position determination result corresponding to the target object is determined, comprising:

[0193] In response to the positional relationship in more than the first set number of continuous frames indicating that the target object is in the set region, the position determination result corresponding to the target object is determined to indicate that the target object enters the set region.

[0194] Specifically, for each target object in the first image, it is determined whether the target object is in the set region in the first image. If the target object is in the set region, the number of image frames in which the target object continuously stays in the set region is obtained. When the number of image frames is more than the first set number, it is indicated that the target object enters the set region. Then, the position determination result of the target object in the first image, i.e., the position determination result at the current time, is determined to indicate that the target object enters the set region.

[0195] In addition, for each target object in the first image, when the target object also exists in the next frame image of the first image, the position determination result of the target object in the first image is taken as the position determination result of the target object at the last time, that is, the position determination result of the target object in the first image is left shifted. When the target object is also in the set region, the number of image frames in which the target object continuously exists in the set region is updated, that is, the number of image frames in which the target object continuously exists in the set region is increased by 1. When the number of image frames in which the target object continuously exists in the set region after the update is greater than a first set number, it is determined that the position determination result of the target object at the current time indicates that the target object enters the set region.

[0196] When the number of image frames in which the target object continuously exists in the set region after the update is less than or equal to the first set number, the position determination result of the target object at the last time is taken as the position determination result of the target object at the current time, and the next frame image is continuously traversed, so as to avoid false detection due to the target object mistakenly entering the set region.

[0197] When the target object is not in the set region, the number of image frames in which the target object continuously exists out of the set region is updated, that is, the number of image frames in which the target object continuously exists out of the set region is increased by 1. If the number of image frames in which the target object continuously exists out of the set region after the update is greater than a second set number, it indicates that the target object has disappeared, and the number of image frames in which the target object continuously exists in the set region is updated to 0.

[0198] In addition, optionally, when it is determined that the number of image frames in which the target object continuously exists in the set region is greater than the first set number, the number of image frames in which the target object continuously exists out of the set region is updated to 0.

[0199] In the embodiment, when the first set number is greater than 1, the position determination result corresponding to the target object is determined according to the position relationship of the target object in multiple image frames, so as to ensure the accuracy of the determined position determination result.

[0200] Optionally, the bounding box of the set region can be single-layer, or can be multi-layer, for example, double-layer, three-layer, etc., in order to prevent shaking and improve the accuracy of flow statistics. Hereinafter, the position relationship of the target object is described by taking a double-layer bounding box as an example.

[0201] When the bounding box of the set region is double-layer, the bounding box of the set region includes an outer bounding box and an inner bounding box (for example, the outer bounding box is a rectangle and the inner bounding box is a circle, as shown in FIG. 2). Figure 5In a case where the head detection frame of the target object is within the inner boundary frame of the set region, the position relationship between the head detection frame and the set region is determined to indicate that the target object is in the set region. In a case where the head detection frame of the target object is between the inner boundary frame and the outer boundary frame of the set region, the position relationship between the head detection frame and the set region is determined according to a second image. The second image is an image before the first image. In a case where the head detection frame of the target object is outside the outer boundary frame of the set region, the position relationship between the head detection frame and the set region is determined to indicate that the target object is not in the set region.

[0202] Specifically, for each target object in the first image, when the head detection frame of the target object is all within a region within the inner boundary frame of the set region, the position relationship between the head detection frame of the target object and the set region is directly determined to indicate that the target object is in the set region. When the head detection frame of the target object is all within a region outside the outer boundary frame of the set region, the position relationship between the head detection frame and the set region is directly determined to indicate that the target object is not in the set region. When the head detection frame of the target object is between the inner boundary frame and the outer boundary frame of the set region, it indicates that the head detection frame of the target object is not all within the inner boundary frame or is not all outside the outer boundary frame, which may be caused by the head detection frame shaking into the set region or shaking out of the set region. Therefore, the position relationship of the target object is determined by combining a second image captured before the first image, so as to realize accurate determination of the position relationship of the target object and further ensure the accuracy of the determined behavior state of the target object.

[0203] Optionally, when the position relationship between the head detection frame of the target object and the set region in the first image is determined by combining the second image, in a case where the position relationship between the head detection frame of the target object and the set region in the second image indicates that the target object is in the set region, the position relationship between the head detection frame of the target object and the set region in the first image is determined to indicate that the target object is in the set region. In a case where the position relationship between the head detection frame of the target object and the set region in the second image indicates that the target object is not in the set region, the position relationship between the head detection frame of the target object and the set region in the first image is determined to indicate that the target object is not in the set region.

[0204] Optionally, the second image can be a previous frame image of the first image, or can be an image spaced apart from the first image by a certain number of images, for example, the number is 1, and the second image is a previous frame image of the previous frame image of the first image.

[0205] Optionally, the number of the set regions can be one or more. When the number of the set regions is more than one, the behavior state of the target object can be determined according to the position determination results of the target object in the set regions. Hereinafter, the number of the set regions is taken as two for example, and the behavior state of the target object is determined according to the position determination results of the target object in the two set regions.

[0206] Specifically, when the number of the set regions is two, the set regions include an entering region and a leaving region. The arrangement of the entering region and the leaving region can be arranged according to the path of entering the target site, for example, as shown in FIG. 3, the entering region is outside the door of the target site, and the leaving region is inside the door of the target site. Correspondingly, the behavior state of the target object is determined according to the position determination results, including: Figure 5

[0207] When the position determination results of the adjacent two indicate that the target object passes through the entering region and the leaving region in sequence, it is determined that the behavior state indicates entering the target site. And / or,

[0208] When the position determination results of the adjacent two indicate that the target object passes through the leaving region and the entering region in sequence, it is determined that the behavior state indicates leaving the target site.

[0209] Specifically, for each target object in the first image, when the position determination results of the adjacent two indicate that the target object passes through the entering region and the leaving region in sequence, it is determined that the behavior state of the target object indicates that the target object enters the entering region and then enters the leaving region, and it is determined that the behavior state of the target object indicates that the target object enters the target site.

[0210] When the position determination results of the adjacent two indicate that the target object passes through the leaving region and the entering region in sequence, it is determined that the behavior state of the target object indicates that the target object passes through the leaving region and then passes through the entering region, and it is determined that the behavior state of the target object indicates that the target object leaves the target site.

[0211] Optionally, one of the position determination results of the adjacent two indicates the position determination result of the determined target object in the last frame of image, and the other indicates the position determination result of the determined target object in the current image (i.e. the first image).

[0212] ​Optionally, the location determination results of two adjacent locations can be represented by corresponding identifiers. For example, when the location determination result indicates that the target object has passed through the entry area, the location determination result is identified as the first identifier; when the location determination result indicates that the target object has passed through the exit area, the location determination result is identified as the second identifier. When the location determination result indicates that the target object has not passed through the designated area (i.e., it has neither passed through the entry area nor the exit area), the location determination result is identified as the third identifier.

[0213] Optionally, the identifier corresponding to the location determination result can also be the identifier corresponding to the set area, for example, such as... Figure 6 As shown, the area to be entered is area 1, and its corresponding identifier is 1. The area to be left is area 2, and its corresponding identifier is 2. Therefore, the first identifier is 1 and the second identifier is 2.

[0214] Optionally, the position determination results of two adjacent objects can be stored in the form of an array. That is, the first element in the array represents the position determination result of the target object in the previous frame, i.e., the previous moment, and the second element in the array represents the position determination result of the target object in the first image, i.e., the current moment.

[0215] Take a specific application scenario as an example, such as Figure 7 The flowchart shown illustrates the traffic statistics process. The first set number is 2, and the image sequence includes 6 frames. The identifier for entering the region is 1, and the identifier for leaving the region is 2. The second set number is also 2. For each target object in the first frame, since it is the first appearance of the target object, the number of consecutive image frames in the set region is initialized to 0, and the number of consecutive image frames not in the set region is also initialized to 0. The target object's position determination result at the previous moment is the third identifier (i.e., 0). If the target object is in the entering region, the number of consecutive image frames in the set region is updated to 1. Since this number does not exceed the first set number, the target object's position determination result at the previous moment is still used as the target object's position determination result at the current moment, i.e., in the first frame. Accordingly, the array corresponding to the target object in the first frame is (0,0), and the detection of the second frame in the image sequence continues.

[0216] When the target object also appears in the second frame image, if the target object is in the entry area, the updated number of consecutive image frames in the set area for the target object is 2, which is still no more than the first set number. Then the array corresponding to the target object in the second frame image is (0,0), and the third frame image in the image sequence continues to be detected.

[0217] When the target object also appears in the third frame image, if the target object is in the entering area, the image frame number of the target object continuously in the set area after updating is 3, which is more than the first set number, because the target object is currently in the entering area, the position determination result of the target object at the current time, i.e. the position determination result in the third frame image, indicates that the target object enters the entering area, correspondingly, the array of the target object in the third frame image is (0, 1), and the image frame number of the target object continuously not in the set area is updated to 0, and the fourth frame image in the image sequence is continuously detected.

[0218] When the target object also appears in the fourth frame image, the position determination result of the target object at the last time is the position determination result of the target object in the third frame image, i.e. the second bit element of the target object is assigned to the first bit element. If the target object is still in the entering area, the image frame number of the target object continuously in the set area after updating is 4, which is more than the first set number, because the target object is currently in the entering area, the position determination result of the target object at the current time, i.e. the position determination result in the fourth frame image, indicates that the target object enters the entering area, correspondingly, the array of the target object in the fourth frame image is (1, 1), and the fifth frame image in the image sequence is continuously detected.

[0219] When the target object also appears in the fifth frame image, the position determination result of the target object at the last time is the position determination result of the target object in the fourth frame image. If the target object is still in the entering area, the image frame number of the target object continuously in the set area after updating is 5, which is more than the first set number, because the target object is currently in the entering area, the position determination result of the target object at the current time, i.e. the position determination result in the fifth frame image, indicates that the target object enters the entering area, correspondingly, the array of the target object in the fourth frame image is (1, 1), and the sixth frame image in the image sequence is continuously detected.

[0220] When the target object also appears in the sixth frame image, the position determination result of the target object at the last time is the position determination result of the target object in the fifth frame image. If the target object is in the leaving area, the image frame number of the target object continuously in the set area after updating is 6, which is more than the first set number, because the target object is currently in the leaving area, the position determination result of the target object at the current time, i.e. the position determination result in the sixth frame image, indicates that the target object enters the leaving area, correspondingly, the array of the target object in the fourth frame image is (1, 2), and the behavior state of the target object indicates that the target object enters the target place.

[0221] In the embodiment, the entering area and the leaving area are set, and whether the target object continuously passes through the entering area and the leaving area is used to determine the behavior state of the target object, so that the accuracy of determining the behavior state of the target object is ensured. Compared with the prior art of determining the behavior state of the target object by using a single set area, the behavior state of the target object can be avoided to be misjudged in various cases, so that the target object is avoided to be miscounted. For example, when the target object enters the single set area, it is determined that the target object enters the target place, but the target object immediately walks out of the set area, at this time, it is determined that the target object leaves the target place, that is, the target object continuously enters and leaves the set area, and continuously hovers at the entrance of the target place, and does not actually enter the target place, so that the target object is repeatedly counted, and the accuracy of flow counting is poor. However, when the entering area and the leaving area are used to determine the behavior state of the target object, the situation can be avoided, so that the accuracy of flow counting is ensured.

[0222] Optionally, when the number of set areas is one, the boundary box corresponding to the set area includes a first boundary line and a second boundary line. The first boundary line is a side of the set area through which the target object enters the target place based on the direction of entering the target place. The second boundary line is a side of the set area through which the target object leaves the target place based on the direction of leaving the target place. The first boundary line and the second boundary line are opposite to each other.

[0223] Correspondingly, the behavior state of the target object is determined according to the position determination result, including:

[0224] In response to the position determination results of the two adjacent positions being different, the boundary line newly passed through by the target object is obtained. The boundary line is the first boundary line or the second boundary line.

[0225] The behavior state of the target object is determined according to the boundary line and the position determination results of the two adjacent positions.

[0226] Specifically, when the position determination results of the two adjacent positions of the target object are different, it indicates that the target object enters and leaves the set area, and the target object may enter or leave the target place, so that the boundary line of the set area newly passed through by the target object is obtained, so as to determine whether the target object enters or leaves the target place by using the boundary line.

[0227] Optionally, the behavior state of the target object is determined according to the boundary line and the position determination results of the two adjacent positions, including:

[0228] In the case that the boundary line is the first boundary line, and the position determination results of the two adjacent positions indicate that the target object enters the set area and does not enter the set area in turn, the behavior state of the target object is determined to be entering the target place.

[0229] And / or,

[0230] In a case where the boundary line is the second boundary line and the two adjacent position determination results successively indicate that the target object enters the set region and does not enter the set region, the behavior state of the target object is determined as leaving the target site.

[0231] Specifically, as shown in Figure 8 the first boundary line is a boundary line of the set region inside the door of the target site, and the second boundary line is a boundary line of the set region outside the door of the target site. When the boundary line that the target object has passed through most recently is the first boundary line, if the two adjacent position determination results corresponding to the target object successively indicate that the target object enters the set region and does not enter the set region, it indicates that the target object enters the region outside the set region in the target site from the set region, and the behavior state of the target object is determined as entering the target site. Similarly, when the boundary line that the target object has passed through most recently is the second boundary line, if the two adjacent position determination results corresponding to the target object successively indicate that the target object enters the set region and does not enter the set region, it indicates that the target object enters the set region from the region outside the target site, and the behavior state of the target object is determined as entering the target site.

[0232] It can be understood that Figure 8 the setting of the first boundary line and the second boundary line, the shape of the set region, and the position of the set region shown in

[0233] Optionally, in order to enable the user to intuitively distinguish the target objects on the image, the object identifier corresponding to the target object can also be displayed on the first image. The specific display process is as follows: obtaining the feature information of each target object on the first image. According to the feature information, the object identifier corresponding to the target object is determined. The object identifier corresponding to the target object is displayed on the first image.

[0234] Specifically, the feature information of each target object on the first image is determined by using a related algorithm or model. For each target object, a corresponding search result is obtained by searching a preset table based on the feature information of the target object, the search result indicating whether the target object appears for the first time in the image sequence, that is, whether the target object appears for the first time in the image captured by the camera, and the object identifier corresponding to the target object is determined according to the search result. The object identifier corresponding to the target object is displayed on the first image (for example, id: 0 in Figure 4 indicates that the object identifier corresponding to the corresponding target object is 0).

[0235] The preset table includes the feature information of the target object appearing in the image sequence and the object identifier corresponding to the target object.

[0236] Optionally, in order to improve the accuracy of the detection of the target object, the clothing and other features of the target object that are obviously different from other target objects can be extracted, and the accessory features such as the skateboard and umbrella are not used, and correspondingly, the feature information of the target object includes clothing feature information and the like of the target object.

[0237] Optionally, the object identifier corresponding to the target object is determined according to the feature information, including:

[0238] In a case where the target object is a first appearance object, an object identifier other than the object identifier contained in the first image is allocated to the target object, and a correspondence between the feature information of the target object and the object identifier is stored in a preset table.

[0239] In a case where the target object is not a first appearance object, the object identifier corresponding to the target object is obtained from the preset table according to the feature information corresponding to the target object.

[0240] Specifically, for each target object in the first image, in a case where the feature information corresponding to the target object is found from the preset table, it is indicated that the search result corresponding to the target object indicates that the target object is not first appeared in the image sequence, that is, is not first appeared in the image captured by the camera device, then the object identifier corresponding to the feature information of the target object is found from the preset table, and the found object identifier is taken as the object identifier corresponding to the target object.

[0241] In a case where the feature information corresponding to the target object is not found from the preset table, it is indicated that the search result corresponding to the target object indicates that the target object is first appeared in the image sequence, that is, is first appeared in the image captured by the camera device, and the feature information of the target object does not exist in the preset table, then a new object identifier is allocated to the target object, the new object identifier is different from the object identifiers corresponding to all feature information in the preset table, and the object identifier of the target object and the feature information of the target object are stored in the preset table.

[0242] Wherein, when allocating a new object identifier to the target object, the allocation can be based on a preset order, for example, the object identifier is a number, the identifier is allocated to the target object in ascending order, the largest object identifier in the preset table is 3, and the new object identifier allocated to the target object is 4.

[0243] Optionally, when the target object in the image sequence disappears, i.e., the target object is not in the frame captured by the camera, i.e., for the target object to which the object identifier has been assigned, if the target object is not detected in more than the second set number of continuous frames, the correspondence between the feature information of the target object and the object identifier is deleted from the preset table, so as to stop tracking and counting the target object. Of course, when the target object in the image sequence disappears, the object relationship between the feature information of the target object and the object identifier can also be retained, which is not limited here.

[0244] Optionally, after deleting the object relationship between the feature information of the target object and the object identifier from the preset table, the object identifier of other target objects in the preset table can also be adjusted. Correspondingly, when other target objects exist on the displayed image, the adjusted object identifier corresponding to the other target objects is displayed.

[0245] When adjusting the object identifier of other target objects in the preset table, the adjustment can be based on a preset order. For example, the preset order is from small to large, and when adjusting, the object identifier of other target objects can be reduced by 1.

[0246] Optionally, the setting area can also be set according to actual needs. The specific process is as follows: a setting area setting request is obtained. The setting area is set correspondingly according to the setting area setting request. The setting processing includes at least one of the setting area opening processing, the setting area closing processing, the setting area corresponding opening time period setting processing, and the interval setting processing between the boundary box and the inner boundary box.

[0247] Specifically, when the user wants to open or close a certain setting area, the user can input a corresponding setting area opening request or a setting area closing request to open or close the setting area on the image. The user can also set the opening time of the setting area. For example, when the user wants to count the number of people in a certain time period, the user can input a corresponding opening time period setting request to open the setting area in the time period. When the boundary box of the setting area is double-layer, the interval distance between the boundary box and the inner boundary box can also be set.

[0248] Optionally, when the boundary box of the setting area is double-layer, the inner boundary box of the setting area can be obtained by shrinking the outer boundary box of the setting area based on the interval distance.

[0249] Of course, the user can also set the setting area according to needs, and the setting processing of the setting area is not limited here.

[0250] In the embodiment, the bounding box of the setting area is set as a double layer, so that misjudgment of the position relationship of the target object caused by shaking of the detection box (for example, the head detection box or the body detection box) corresponding to the target object can be avoided, the determination accuracy of the position determination result of the target object is improved, and the accuracy of the flow statistical result of the determined target place is further improved.

[0251] Corresponding to the embodiments of the foregoing method, the application further provides embodiments of a device and a terminal to which the device is applied.

[0252] The embodiments of the flow statistical device of the application can be applied to a computer device, for example, a server or a terminal device. The device embodiments can be implemented by software, or by hardware or a combination of software and hardware. For example, in the case of software implementation, as a logically meaningful device, the device is formed by a processor reading corresponding computer program instructions in a non-volatile memory into a memory for execution. From the hardware level, as shown in Figure 9 , it is a hardware structure diagram of a computer device where the flow statistical device of the embodiments of the application is located. In addition to the processor 910, the memory 930, the network interface 920, and the non-volatile memory 940 shown in Figure 9 , the computer device where the device 931 in the embodiments is located usually includes other hardware according to the actual functions of the computer device, and details are not repeated.

[0253] As shown in Figure 10 , Figure 10 is a block diagram of a flow statistical device according to an exemplary embodiment of the present specification, and the device includes:

[0254] The image acquisition module 1010 is configured to acquire a first image of a target place.

[0255] The image processing module 1020 is configured to perform body detection on the first image to obtain a body detection box of each target object in the first image. The body detection box indicates a body region of the target object.

[0256] The head determination module 1030 is configured to, for each target object, determine a head detection box of the target object according to the body detection box of the target object. The head detection box indicates a head region of the target object.

[0257] The flow statistical module 1040 is configured to obtain a flow statistical result of the target place according to the head detection box of each target object.

[0258] Optionally, the head determination module 1030 is specifically configured to:

[0259] acquire the width and the height of the body detection box.

[0260] The body bounding box is reduced according to the width and the height, to obtain a head bounding box.

[0261] Optionally, the target object is a human.

[0262] The head determination module 1030 is further specifically configured to:

[0263] The width-height ratio of the body bounding box is determined according to the width and the height of the body bounding box.

[0264] A target preset ratio range to which the width-height ratio of the body bounding box belongs is obtained, wherein the preset ratio range is determined based on a human body posture of the target object.

[0265] A height reduction ratio corresponding to the target preset ratio range is obtained, and a reduction operation is performed on the body bounding box in the height direction based on the height reduction ratio.

[0266] Optionally, the head determination module 1030 is specifically configured to:

[0267] A reduction operation is performed on the body bounding box in the width direction based on a preset width reduction ratio.

[0268] Alternatively,

[0269] A width reduction ratio corresponding to the target preset ratio range is obtained, and a reduction operation is performed on the body bounding box in the width direction based on the width reduction ratio.

[0270] Optionally, the flow statistics module 1040 is specifically configured to:

[0271] For each target object, a behavior state of the target object is determined according to a positional relationship between the head bounding box of the target object and a set region in the first image of the target site, wherein the behavior state of the target object indicates whether the target object enters or exits the target site.

[0272] A flow statistics result of the target site is determined according to the behavior state of each target object.

[0273] Optionally, the flow statistics module 1040 is further specifically configured to:

[0274] A position determination result corresponding to the target object is determined according to a positional relationship between the head bounding box of the target object and a set region in the first image of the target site, wherein the position determination result indicates whether the target object enters the set region.

[0275] The behavior state of the target object is determined according to the position determination result.

[0276] Optionally, the set region includes an entering region and an exiting region.

[0277] The flow counting module 1040 is further configured to:

[0278] In a case where the two adjacent position determination results successively indicate that the target object passes through the entering area and the leaving area, it is determined that the behavior state indicates entering the target site. And / or,

[0279] In a case where the two adjacent position determination results successively indicate that the target object passes through the leaving area and the entering area, it is determined that the behavior state indicates leaving the target site.

[0280] Optionally, the first image is one frame in the image sequence. The position relationship indicates whether the target object is in the set area.

[0281] The flow counting module 1040 is further configured to:

[0282] In response to the position relationship in more than the first set number of continuous frames indicating that the target object is in the set area, it is determined that the position determination result corresponding to the target object indicates that the target object enters the set area.

[0283] Optionally, the boundary box of the set area includes an outer boundary box and an inner boundary box.

[0284] The flow counting module 1040 is further configured to:

[0285] In a case where the head detection box of the target object is within the inner boundary box of the set area, it is determined that the position relationship between the head detection box and the set area indicates that the target object is in the set area.

[0286] In a case where the head detection box of the target object is between the inner boundary box and the outer boundary box of the set area, the position relationship between the head detection box and the set area is determined according to a second image. The second image is an image before the first image.

[0287] In a case where the head detection box of the target object is outside the outer boundary box of the set area, it is determined that the position relationship between the head detection box and the set area indicates that the target object is not in the set area.

[0288] Optionally, the flow counting module 1040 is further configured to:

[0289] In a case where the position relationship between the head detection box of the target object and the set area in the second image indicates that the target object is in the set area, it is determined that the position relationship between the head detection box of the target object and the set area in the first image indicates that the target object is in the set area.

[0290] In a case where the positional relationship between the head bounding box of the target object and the set region in the second image indicates that the target object is not in the set region, the positional relationship between the head bounding box of the target object and the set region in the first image is determined to indicate that the target object is not in the set region.

[0291] Optionally, the apparatus further comprises a region setting module.

[0292] The region setting module is specifically configured to:

[0293] Obtain a set region setting request.

[0294] Perform corresponding setting processing on the set region according to the set region setting request. The setting processing includes at least one of set region opening processing, set region closing processing, set region corresponding opening time period setting processing, and interval setting processing between the boundary box and the inner boundary box.

[0295] Optionally, the set region corresponding boundary box includes a first boundary line and a second boundary line. The first boundary line is a side of the set region through which the target site is entered, which is pre-set based on the direction of entering the target site. The second boundary line is a side of the set region through which the target site is exited, which is pre-set based on the direction of exiting the target site. The first boundary line and the second boundary line are opposite to each other.

[0296] The flow statistics module 1040 is further specifically configured to:

[0297] In response to the position determination results of the two adjacent positions being different, a latest boundary line through which the target object passes is obtained. The boundary line is the first boundary line or the second boundary line.

[0298] According to the boundary line and the position determination results of the two adjacent positions, a behavior state of the target object is determined.

[0299] Optionally, the flow statistics module 1040 is further specifically configured to:

[0300] In a case where the boundary line is the first boundary line, and the position determination results of the two adjacent positions indicate that the target object enters the set region and does not enter the set region in sequence, the behavior state of the target object is determined to be entering the target site.

[0301] And / or,

[0302] In a case where the boundary line is the second boundary line, and the position determination results of the two adjacent positions indicate that the target object enters the set region and does not enter the set region in sequence, the behavior state of the target object is determined to be exiting the target site.

[0303] Optionally, the apparatus further comprises an object identification determination module.

[0304] The object identification determining module is specifically configured to:

[0305] Obtain feature information of each target object on the first image.

[0306] Determine an object identification corresponding to the target object according to the feature information.

[0307] Display the object identification corresponding to the target object on the first image.

[0308] Optionally, the object identification determining module is further configured to:

[0309] In a case where the target object is a first appearance object, assign an object identification other than the object identification contained in the first image to the target object, and store a correspondence between the feature information of the target object and the object identification in a preset table.

[0310] In a case where the target object is not a first appearance object, obtain the object identification corresponding to the target object from the preset table according to the feature information corresponding to the target object.

[0311] Optionally, the object identification determining module is further configured to:

[0312] For the target object to which the object identification has been assigned, in a case where the target object is not detected in more than a second set number of continuous frames, delete the correspondence between the target object and the object identification from the preset table.

[0313] In another embodiment, the present application further provides a computer readable storage medium, wherein computer execution instructions are stored in the computer readable storage medium, and when a processor executes the computer execution instructions, the traffic statistical method is realized.

[0314] In another embodiment, a computer program product is provided, comprising a computer program, and when the computer program is executed by a processor, the traffic statistical method is realized.

[0315] For the device embodiment, since it basically corresponds to the method embodiment, the related parts are described in the part of the method embodiment. The device embodiment described above is only illustrative, wherein the units described as separate components can be or can not be physically separated, and the components displayed as units can be or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. According to actual needs, part or all of the modules can be selected to achieve the purpose of the embodiment. Those skilled in the art can understand and implement it without creative labor.

[0316] It is to be noted that, in the present document, relational terms such as first and second and the like can be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. The terms "comprises", "comprising", or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element. The data addressed in the present application can be data authorized by a user or data sufficiently authorized by parties.

[0317] The above detailed description of the method and device provided by the embodiments of the present application has been introduced in detail, the principle and implementation mode of the present application are described by applying specific examples in the present document, the above embodiment explanation is only for helping to understand the method of the present application and its core idea; meanwhile, for the general technical personnel in the field, according to the idea of the present application, the specific implementation mode and application range will have changes, and the above-mentioned description should not be understood as the limitation of the present application.

Claims

1. A method of flow statistics, characterized by, The method comprises: obtaining a first image of a target site; performing body detection on the first image to obtain a body detection frame of each target object in the first image; wherein the body detection frame indicates a body region of the target object, and the target object is a person; for each target object, determining a head detection frame of the target object according to the body detection frame of the target object, comprising: obtaining a width and a height of the body detection frame; determining an aspect ratio of the body detection frame according to the width and the height of the body detection frame; obtaining a target preset ratio range to which the aspect ratio of the body detection frame belongs; wherein the preset ratio range is determined based on a human posture of the target object; obtaining a height reduction ratio corresponding to the target preset ratio range, and performing a reduction operation on the body detection frame in a height direction based on the height reduction ratio to obtain the head detection frame; wherein the head detection frame indicates a head region of the target object; obtaining a traffic statistical result of the target site according to the head detection frame of each target object.

2. The method of claim 1, wherein, The method further comprises: performing a reduction operation on the body detection frame in a width direction based on a preset width reduction ratio.

3. The method of claim 1, wherein, The method of obtaining a traffic statistical result of the target site according to the head detection frame of each target object comprises: for each target object, determining a behavior state of the target object according to a positional relationship between the head detection frame of the target object and a set region in the first image of the target site, wherein the behavior state of the target object indicates whether the target object enters or exits the target site; determining the traffic statistical result of the target site according to the behavior state of each target object.

4. The method of claim 3, wherein, The method of determining the behavior state of the target object according to the positional relationship between the head detection frame of the target object and the set region in the first image of the target site comprises: determining a position determination result corresponding to the target object according to the positional relationship between the head detection frame of the target object and the set region in the first image of the target site; wherein the position determination result indicates whether the target object enters the set region; determining the behavior state of the target object according to the position determination result.

5. The method of claim 4, wherein, The set region comprises an entering region and an exiting region; The method of determining the behavior state of the target object according to the position determination result comprises: in a case where two adjacent position determination results successively indicate that the target object passes through the entering region and the exiting region, determining that the behavior state indicates entering the target site; and / or, in a case where two adjacent position determination results successively indicate that the target object passes through the exiting region and the entering region, determining that the behavior state indicates exiting the target site.

6. The method of claim 4, wherein, The first image is one frame in an image sequence; the positional relationship indicates whether the target object is in the set region; The method of determining a position determination result corresponding to the target object according to the positional relationship between the head detection frame of the target object and the set region in the first image of the target site comprises: In response to the position relationship indication in more than a first set number of continuous frames indicating that the target object is in a set region, a position determination result corresponding to the target object is determined to indicate that the target object enters the set region.

7. The method of claim 3, wherein, The boundary box of the set region includes an outer boundary box and an inner boundary box. The method further includes: In a case where the head detection box of the target object is within the inner boundary box of the set region, a position relationship between the head detection box and the set region is determined to indicate that the target object is in the set region; In a case where the head detection box of the target object is between the inner boundary box and the outer boundary box of the set region, a position relationship between the head detection box and the set region is determined according to a second image; the second image is an image before the first image; In a case where the head detection box of the target object is outside the outer boundary box of the set region, a position relationship between the head detection box and the set region is determined to indicate that the target object is not in the set region.

8. The method of claim 7, wherein, The position relationship between the head detection box and the set region according to the second image includes: In a case where the position relationship between the head detection box of the target object and the set region in the second image indicates that the target object is in the set region, the position relationship between the head detection box of the target object and the set region in the first image is determined to indicate that the target object is in the set region; In a case where the position relationship between the head detection box of the target object and the set region in the second image indicates that the target object is not in the set region, the position relationship between the head detection box of the target object and the set region in the first image is determined to indicate that the target object is not in the set region.

9. The method of claim 7, wherein, The method further includes: Obtaining a set region setting request; According to the set region setting request, corresponding setting processing is performed on the set region; the setting processing includes at least one of set region opening processing, set region closing processing, set region corresponding opening time period setting processing, interval setting processing between the boundary box and the inner boundary box.

10. The method of claim 4, wherein, The boundary box corresponding to the set region includes a first boundary line and a second boundary line; the first boundary line is a side of the set region that the target place passes through, which is preset based on the direction of entering the target place; the second boundary line is a side of the set region that the target place passes through, which is preset based on the direction of leaving the target place; the first boundary line and the second boundary line are opposite to each other. The behavior state of the target object is determined according to the position determination result, including: In response to the position determination results of two adjacent positions being different, a latest boundary line passed by the target object is obtained; the boundary line is the first boundary line or the second boundary line; The behavior state of the target object is determined according to the boundary line and the position determination results of the two adjacent positions.

11. The method of claim 10, wherein, The behavior state of the target object is determined according to the boundary line and the position determination results of the two adjacent positions, including: In a case where the boundary line is a first boundary line and the position determination results of the two adjacent objects successively indicate that the target object enters a set region and does not enter the set region, the behavior state of the target object is determined as entering the target site. And / or, In a case where the boundary line is a second boundary line and the position determination results of the two adjacent objects successively indicate that the target object enters a set region and does not enter the set region, the behavior state of the target object is determined as leaving the target site.

12. The method according to any one of claims 1 to 11, characterized in that, The method further comprises: obtaining feature information of each target object on the first image; determining an object identifier corresponding to the target object according to the feature information; displaying the object identifier corresponding to the target object on the first image.

13. The method of claim 12, wherein, The determination of the object identifier corresponding to the target object according to the feature information comprises: in a case where the target object is a first appearance object, assigning an object identifier other than the object identifiers contained in the first image to the target object, and storing a correspondence between the feature information of the target object and the object identifier in a preset table; in a case where the target object is not a first appearance object, obtaining the object identifier corresponding to the target object from the preset table according to the feature information corresponding to the target object.

14. The method of claim 13, wherein, The method further comprises: in a case where a target object to which an object identifier has been assigned is not detected in more than a second set number of consecutive frames, deleting the correspondence between the feature information of the target object and the object identifier from the preset table.

15. A flow metering device, characterized by Comprise: an image acquisition module configured to acquire a first image of a target site; an image processing module configured to perform body detection on the first image to obtain a body detection frame of each target object in the first image; wherein the body detection frame indicates a body region of the target object, and the target object is a person; a head determination module configured to, for each target object, determine a head detection frame of the target object according to the body detection frame of the target object; wherein the head detection frame indicates a head region of the target object; a flow statistics module configured to obtain a flow statistics result of the target site according to the head detection frame of each target object; The head determination module is specifically configured to: obtain the width and height of the body detection frame; determine the aspect ratio of the body detection frame according to the width and height of the body detection frame; obtain a target preset ratio range to which the aspect ratio of the body detection frame belongs; wherein the preset ratio range is determined based on the human posture of the target object; obtain a height reduction ratio corresponding to the target preset ratio range, and perform a height reduction operation on the body detection frame based on the height reduction ratio to obtain the head detection frame.

16. A computer device, comprising: A computer program product comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the following method when executing the program: acquire a first image of a target site; perform body detection on the first image to obtain a body detection frame of each target object in the first image, the target object being a person; wherein the body detection frame indicates a body region of the target object; For each target object, determining a head detection frame of the target object according to the body detection frame of the target object, including: obtaining a width and a height of the body detection frame; determining an aspect ratio of the body detection frame according to the width and the height of the body detection frame; obtaining a target preset ratio range to which the aspect ratio of the body detection frame belongs; wherein the preset ratio range is determined based on a human body posture of a target object; obtaining a height reduction ratio corresponding to the target preset ratio range, and performing a reduction operation on the body detection frame in a height direction based on the height reduction ratio to obtain the head detection frame; wherein the head detection frame indicates a head region of the target object; obtaining a flow statistical result of the target place according to the head detection frame of each target object.

17. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer execution instructions, and when the processor executes the computer execution instructions, the flow statistical method in any one of claims 1 to 14 is implemented.

Citation Information

Patent Citations

  • Human flow statistics method and terminal device

    CN107330386A

  • A passenger flow statistics method and system based on head and shoulder detection

    CN109448026A

  • Object monitoring and tracking method and device and electronic equipment

    CN113011258A