# Patent

## Title
Pedestrian tracking and counting method and device for near-front top-view monitoring video

## Abstract

Provided are a pedestrian tracking and counting method and device for a near-front top-view monitoring video, wherein the method includes that a video image under a current monitoring scene is acquired, the acquired video image is compared with a background image, and when it is determined that the video image is a foreground image, each blob in the foreground image is segmented and combined to acquire a target blob representing an individual pedestrian, and tracking and counting are performed according to the center-of-mass coordinate of each target blob in a detection area to acquire the number of pedestrians under the current monitoring scene. Thus the accuracy of a counting result can be improved.

## Background
TECHNICAL FIELD
The present disclosure relates to an intelligent video monitoring technology, and particularly to a pedestrian tracking and counting method and device for a near-front top-view monitoring video.
BACKGROUND
At present, intelligent video monitoring has been widely applied in many fields, and pedestrian tracking and counting via a near-front top-view monitoring video is a typical application of intelligent video monitoring.
However, an existing technology for pedestrian tracking and counting via a near-front top-view monitoring video can only count separated pedestrians accurately, but fails to count a plurality of stuck pedestrians accurately. Since a plurality of pedestrians are usually stuck in a crowded occasion, such as a subway, a department store and so on, the existing technology for pedestrian tracking and counting via a near-front top-view monitoring video acquires a counting result with relatively low accuracy and thus fails to play a due role.
SUMMARY
In view of this, embodiments of the present disclosure provide a pedestrian tracking and counting method and device for a near-front top-view monitoring video so as to improve the accuracy of a counting result.
Technical solutions of the embodiments of the present disclosure are implemented by the following way to achieve the purpose.
An embodiment of the present disclosure provides a pedestrian tracking and counting method for a near-front top-view monitoring video. The method includes that:
a video image under a current monitoring scene is acquired;
the video image is compared with a background image, and when it is determined that the video image is a foreground image, each blob in the foreground image is segmented and combined to acquire a target blob representing an individual pedestrian; and
tracking and counting are performed according to a centre-of-mass coordinate of each target blob in a detection area to acquire the number of pedestrians under the current monitoring scene.
Preferably, segmenting each blob in the foreground image may include that:
a blob having a width of a circumscribed rectangle of the blob greater than twice a threshold TW of a width of an individual is segmented by equal width according to TW;
a blob having a height of a circumscribed rectangle of the blob greater than twice a threshold TH of a height of an individual is segmented by equal height according to TH; and
a blob having an area smaller than a predetermined threshold is deleted, wherein the blob is acquired after the segmenting.
Preferably, combining each blob in the foreground image may include that:
two blobs having a centre-of-mass horizontal distance not exceeding TW and a centre-of-mass longitudinal distance not exceeding TH are combined;
the width of a circumscribed rectangle of each acquired combined blob is divided by TW and then is subjected to rounding to acquire NW, and the height of the circumscribed rectangle is divided by TH and then is subjected to rounding to acquire NH;
whether NW and NH of each combined blob are smaller than 2 is determined respectively; if greater than 2, then the combined blob is split; if smaller than 2, then the combined blob is retained; and
the three foregoing steps are repeated until all blobs are combined.
Preferably, after it is determined that the video image is a foreground image, the method may further include that:
a background image and a background amplitude are updated with different updating rate coefficients according to an image of a current frame.
Preferably, performing tracking may include that:
each target blob in the detection area is tracked using a nearest proximity matching algorithm, wherein a cost function applied by the nearest proximity matching algorithm is a Euclidean distance.
An embodiment of the present disclosure provides a pedestrian tracking and counting device for a near-front top-view monitoring video. The device includes:
a video image acquiring unit, configured to acquire a video image under a current monitoring scene;
a target blob acquiring unit, configured to compare the video image with a background image, and when it is determined that the video image is a foreground image, segment and combine each blob in the foreground image to acquire a target blob representing an individual pedestrian;
a pedestrian number counting unit, configured to perform tracking and counting according to a centre-of-mass coordinate of each target blob in a detection area to acquire the number of pedestrians under the current monitoring scene.
Preferably, the target blob acquiring unit may be configured to:
segment a blob having a width of a circumscribed rectangle of the blob greater than twice a threshold TW of the width of an individual by equal width according to TW;
segment a blob having a height of a circumscribed rectangle of the blob greater than twice a threshold TH of the height of an individual by equal height according to TH; and
delete a blob having an area smaller than a predetermined threshold, wherein the blob is acquired after the segmenting.
Preferably, the target blob acquiring unit may be further configured to:
combine two blobs having a centre-of-mass horizontal distance not exceeding TW and a centre-of-mass longitudinal distance not exceeding TH;
divide the width of a circumscribed rectangle of each acquired combined blob by TW and then perform rounding to acquire NW, and divide the height of the circumscribed rectangle by TH and then perform rounding to acquire NH;
determine whether NW and NH of each combined blob are smaller than 2 respectively; if greater than 2, then split the combined blob; if smaller than 2, then retain the combined blob; and
repeat the three foregoing steps until all blobs are combined.
Preferably, the device may further include:
an updating unit, configured to update a background image and a background amplitude with different updating rate coefficients according to an image of a current frame.
Preferably, the pedestrian number counting unit may be configured to track each target blob in the detection area using a nearest proximity matching algorithm, wherein a cost function applied by the nearest proximity matching algorithm is a Euclidean distance.
It may be learned from the foregoing that the technical solutions of the embodiments of the present disclosure include that a video image under a current monitoring scene is acquired; the acquired video image is compared with a background image; when it is determined that the video image is a foreground image, each blob in the foreground image is segmented and combined to acquire a target blob representing an individual pedestrian; tracking and counting are performed according to the centre-of-mass coordinate of each target blob in a detection area to acquire the number of pedestrians under the current monitoring scene. Thus, the accuracy of a counting result can be improved.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a diagram of an implementation process of a pedestrian tracking and counting method for a near-front top-view monitoring video according to a first embodiment of the present disclosure;
FIG. 2 is a structural diagram of a pedestrian tracking and counting device for a near-front top-view monitoring video according to an embodiment of the present disclosure;
FIG. 3 is a diagram of an implementation process of a pedestrian tracking and counting method for a near-front top-view monitoring video according to a second embodiment the present disclosure;
FIG. 4 is a schematic diagram of a detection area; and
FIG. 5 is a schematic diagram of a detection area in a practical application scenario.



DETAILED DESCRIPTION
FIG. 1 shows a first embodiment of a pedestrian tracking and counting method for a near-front top-view monitoring video according to the present disclosure. The method includes the following steps:
Step 101: A video image under a current monitoring scene is acquired;
Step 102: The acquired video image is compared with a background image, and when it is determined that the acquired video image is a foreground image, each blob in the foreground image is segmented and combined to acquire a target blob representing an individual pedestrian; and
Step 103: Tracking and counting are performed according to the centre-of-mass coordinate of each target blob in a detection area to acquire the number of pedestrians under the current monitoring scene.
Preferably, segmenting each blob in the foreground image includes that:
a blob having a width of a circumscribed rectangle of the blob greater than twice a threshold TW of the width of an individual is segmented by equal width according to TW;
a blob having a height of a circumscribed rectangle of the blob greater than twice a threshold TH of the height of an individual is segmented by equal height according to TH; and
a blob having an area smaller than a predetermined threshold is deleted, wherein the blob is acquired after the segmenting.
Preferably, combining each blob in the foreground image includes that:
two blobs having a centre-of-mass horizontal distance not exceeding TW and a centre-of-mass longitudinal distance not exceeding TH are combined;
the width of a circumscribed rectangle of each acquired combined blob is divided by TW and then is subjected to rounding to acquire NW, and the height of the circumscribed rectangle is divided by TH and then is subjected to rounding to acquire NH;
whether NW and NH of each combined blob are smaller than 2 is determined respectively; if greater than 2, then the combined blob is split; if smaller than 2, then the combined blob is retained; and
the three foregoing steps are repeated until all blobs are combined.
Preferably, after it is determined that the acquired video image is a foreground image, the method further includes that:
a background image and a background amplitude are updated with different updating rate coefficients according to an image of a current frame.
Preferably, performing the tracking includes that:
each target blob in the detection area is tracked using a nearest proximity matching algorithm, wherein a cost function applied by the nearest proximity matching algorithm is a Euclidean distance.
FIG. 2 shows a pedestrian tracking and counting device for a near-front top-view monitoring video according to the present disclosure. The device includes:
a video image acquiring unit 201, configured to acquire a video image under a current monitoring scene;
a target blob acquiring unit 202, configured to compare the acquired video image with a background image, and when it is determined that the acquired video image is a foreground image, segment and combine each blob in the foreground image to acquire a target blob representing an individual pedestrian; and
a pedestrian number counting unit 203, configured to perform tracking and counting according to the centre-of-mass coordinate of each target blob in a detection area to acquire the number of pedestrians under the current monitoring scene.
Preferably, the target blob acquiring unit 202 is configured to segment a blob having a width of a circumscribed rectangle of the blob greater than twice a threshold TW of the width of an individual by equal width according to TW;
segment a blob having a height of a circumscribed rectangle of the blob greater than twice a threshold TH of the height of an individual by equal height according to TH;
delete a blob having an area smaller than a predetermined threshold, wherein the blob is acquired after the segmenting.
Preferably, the target blob acquiring unit 202 is further configured to combine two blobs having a centre-of-mass horizontal distance not exceeding TW and a centre-of-mass longitudinal distance not exceeding TH;
divide the width of a circumscribed rectangle of each acquired combined blob by TW and then perform rounding to acquire NW, and divide the height of the circumscribed rectangle by TH and then perform rounding to acquire NH;
determine whether NW and NH of each combined blob are smaller than 2 respectively; if greater than 2, then split the combined blob; and if smaller than 2, then retain the combined blob; and
repeat the three foregoing steps until all blobs are combined.
Preferably, as shown in FIG. 2, the device further includes:
an updating unit 204, configured to update a background image and a background amplitude with different updating rate coefficients according to an image of a current frame.
Preferably, the pedestrian number counting unit 203 is configured to track each target blob in the detection area using a nearest proximity matching algorithm, wherein a cost function applied by the nearest proximity matching algorithm is a Euclidean distance.
In a practical application, the video image acquiring unit 201 may be implemented by a camera.
The target blob acquiring unit 202, the pedestrian number counting unit 203 and the updating unit 204 may be implemented by a Central Processing unit (CPU), a Digital Signal Processor (DSP) or a Field-Programmable Gate Array (FPGA).
In a practical application, the pedestrian tracking and counting device for a near-front top-view monitoring video may be applied in a video monitoring apparatus.
A second embodiment of a pedestrian tracking and counting method for a near-front top-view monitoring video according to the present disclosure will be introduced below in combination with FIG. 3.
Step 301 includes that a video image under a current monitoring scene is acquired.
Step 302 includes that median filter processing is performed for the acquired video image.
Specifically, a 3*3 rectangular sliding filter window is selected. The signal amplitudes of 9 different or same pixels in the window are sorted by size, and a median signal amplitude of the sequence is outputted as the signal amplitude of a central pixel of the window.
Step 303 includes that whether there is a background image and a background amplitude is determined. When there are no background image and background amplitude, Step 304 is performed. When there are background image and background amplitude, Step 305 is performed.
Step 304 includes that a background is modeled according to the video image having been subjected to the median filter processing, so as to acquire a background image and a background amplitude.
Specifically, an average value of video images of M initial frames is calculated to acquire an average image as the background image. A standard deviation between images of N frames and an initial background is calculated, and a value which is √{square root over (2)} times of the standard deviation is used as the background amplitude.
Step 305 includes that whether an image of a current frame is a background image or a foreground image is determined according to the background image and the background amplitude. When it is determined that the image is a foreground image, Step 306 is performed. When it is determined that the image is a background image, Step 301 is performed again.
Specifically, the inputted video image is compared with an initial background image and an initial background amplitude. If the signal amplitudes of three channels of pixels in the inputted video image are all in an amplitude range of the signal amplitudes of pixels of the background image, it is determined that the video image is a background image. If the signal amplitudes of three channels of pixels in the inputted video image are not all in an amplitude range of the signal amplitudes of pixels of the background image, it is determined that the video image is a foreground image.
Step 306 includes that the background image and the background amplitude are updated according to the image of the current frame.
Specifically, a standard deviation between the image of the current frame and the background image is calculated and the signal amplitude of the image of the current frame is obtained. The background image and the background amplitude are updated with different updating rate coefficients according to a foreground part and a background part of the image of the current frame by using an averaged sliding method. The background part is updated with a relatively high rate while the background amplitude is updated with a relatively low rate. The background part is updated with a relatively high rate in order to keep acquiring an accurate background so as to adapt to a slow background change. The background amplitude is updated with a relatively low rate in order to adapt to a sudden background change caused by addition of a new background object and so on.
Step 307 includes that a shade in a foreground image of the current frame is removed.
Specifically, the image of the current frame and the background image are transferred from a Red-Green-Blue (RGB) space into a Hue-Saturation-Value (HSV) space. Hues and saturations are normalized into a range of 0 to 1, and lightness is normalized into a range of 0 to 255. Foreground pixels of the image of the current frame are compared with corresponding pixels of the background image in the HSV space. If a hue and saturation difference of a pixel is smaller than a predetermined hue and saturation threshold and a lightness ratio is smaller than a predetermined lightness ratio threshold, it is determined that the pixel is a shade, and the pixel is removed from the foreground image so as to acquire a modified foreground image.
Step 308 includes that each blob in the modified foreground image is segmented and combined to acquire a target blob representing an individual pedestrian.
Specifically the step 308 includes step 3081 to step 3089. Step 3081 includes that a blob having a width of a circumscribed rectangle of the blob greater than twice a threshold TW of the width of an individual is segmented by equal width according to Equation (1):

NW=floor(W/TW)  (1)

Step 3082 includes that a blob having a height of a circumscribed rectangle of the blob greater than twice a threshold TH of the height of an individual is segmented by equal height according to Equation (2):

NH=floor(H/TH)  (2)

In the foregoing equations, W and H represent the width and height of a circumscribed rectangle of a blob respectively, and floor is a rounding operation.
Step 3083 includes that a blob having an area smaller than a predetermined threshold is deleted, wherein the blob is acquired after the segmenting.
Step 3084 includes that two blobs having a centre-of-mass horizontal distance not exceeding TW and a centre-of-mass longitudinal distance not exceeding TH are combined.
Step 3085 includes that the width of a circumscribed rectangle of each acquired combined blob is introduced into Equation (1) to acquire NW, and the height of the circumscribed rectangle is introduced into Equation (2) to acquire NH, respectively.
Step 3086 includes that whether NW and NH of each combined blob are smaller than 2 is determined respectively; if greater than 2, then the combined blob is split, and if smaller than 2, then the combined blob is retained.
Step 3084 to Step 3086 are repeated until all blobs are combined.
Step 309 includes that tracking and counting are performed according to the centre-of-mass coordinate of each target blob in a detection area to acquire the number of pedestrians under the current monitoring scene.
Specifically, each target blob in the detection area is tracked using a nearest proximity matching algorithm, wherein a cost function applied by the nearest proximity matching algorithm is a Euclidean distance.

I(i,j)=√{square root over ((Xti−Xt+1j)2+(Yt1−Yt+1j)2)}  (3)

where (Xti, Ytj) represents the centre-of-mass coordinate of a target blob i of the tth frame, and (Xt+1i, Yt+1j) represents the centre-of-mass coordinate of a target blob j of the (t+1)th frame.
While the tracking is performed, a tracker is created to record the coordinates of all trajectories of a target from appearance to disappearance in the detection area.
Provided that m target blobs S1, S2 . . . Sm are detected currently, and there are already n target blobs in the current frame which are respectively corresponding to trackers T1, T2 . . . Tn; a specific matching algorithm is calculating a Euclidean distance D=(D1, D2 . . . Dn) between any target blob S1 of the current frame and latest coordinates recorded by all trackers (i.e. the coordinate of a target matched and recorded by the last frame). If dj=min(D) and dj<Tn, then it is considered that a target blob corresponding to a tracker Tj and Si are closest. Si is a location where the target blob corresponding to the tracker Tj appears in the current frame. Si is added to Tj so as to match a target and record the coordinate of a trajectory.
In a situation that a matching target blob of the current frame is not found in a nearest proximity matching process, if the target blob is located in a target appearance and disappearance area, then it is determined that the target blob is a new target blob, and a record of the new target blob is created by a tracker.
In a situation that a matching target blob corresponding to a tracker is found in a nearest proximity matching process, if the following conditions are satisfied: {circumflex over (1)}. the number (the length of the tracker) of frames of the target blob in the detection area is larger than a threshold; {circumflex over (2)} the final coordinate of a tracking record is in a target appearance and disappearance area; {circumflex over (3)} the displacement of the target blob is greater than a threshold, then an advancing direction is determined according to locations where the target blob appears and disappears, and a count is accumulated by a corresponding counter so as to acquire an accumulated value of pedestrians coming in and going out under the current monitoring scene.
The detection area is generated according to the centres of two predetermined detection borders and a weight and height threshold T of a predetermined target pedestrian. The weight and height threshold T of the predetermined target pedestrian may be a relatively large value of weight and height thresholds of target pedestrians. Specifically, as shown in FIG. 4, a detection area is formed by an area extending from a line connecting two centres in two vertical directions for half of a target pedestrian weight and height threshold T. The detection area is divided into three equal areas in a direction parallel to the line connecting the two centres. Two areas at two ends are target appearance and disappearance areas. Detection borders of the detection area may not be parallel to a road direction, as shown in FIG. 5.
The foregoing descriptions are only preferred embodiments of the present disclosure and are not used for limiting the protection scope of the present disclosure.

## Claims

1. A pedestrian tracking and counting method for a near-front top-view monitoring video, comprising:
acquiring a video image under a current monitoring scene;
comparing the video image with a background image, and when it is determined that the video image is a foreground image, segmenting and combining each blob in the foreground image to acquire a target blob representing an individual pedestrian;
performing tracking and counting according to a centre-of-mass coordinate of each target blob in a detection area to acquire the number of pedestrians under the current monitoring scene,
wherein segmenting each blob in the foreground image comprises:
segmenting a blob having a width of a circumscribed rectangle of the blob greater than twice a threshold TW of a width of an individual by equal width according to TW;
segmenting a blob having a height of a circumscribed rectangle of the blob greater than twice a threshold TH of a height of an individual by equal height according to TH;
deleting a blob having an area smaller than a predetermined threshold, wherein the blob is acquired after the segmenting.

2. The method according to claim 1, wherein combining each blob in the foreground image comprises:
combining two blobs having a centre-of-mass horizontal distance not exceeding TW and a centre-of-mass longitudinal distance not exceeding TH;
dividing a width of a circumscribed rectangle of each acquired combined blob by TW and then performing rounding to acquire a first value NW, and dividing a height of the circumscribed rectangle by TH and then performing rounding to acquire a second value NH;
determining whether NW and NH of each combined blob are smaller than 2 respectively; if greater than 2, then splitting the combined blob; if smaller than 2, then retaining the combined blob; and
repeating the three foregoing steps until all blobs are combined.

3. The method according to claim 1, after it is determined that the video image is a foreground image, the method further comprising:
updating a background image and a background amplitude with different updating rate coefficients according to an image of a current frame.

4. The method according to claim 1, wherein performing tracking comprises:
tracking each target blob in the detection area using a nearest proximity matching algorithm, wherein a cost function applied by the nearest proximity matching algorithm is a Euclidean distance.

5. A pedestrian tracking and counting device for a near-front top-view monitoring video, comprising:
a video image acquiring unit, configured to acquire a video image under a current monitoring scene;
a target blob acquiring unit, configured to compare the video image with a background image, and to, when it is determined that the video image is a foreground image, segment and combine each blob in the foreground image to acquire a target blob representing an individual pedestrian; and
a pedestrian number counting unit, configured to perform tracking and counting according to a centre-of-mass coordinate of each target blob in a detection area to acquire the number of pedestrians under the current monitoring scene,
wherein the target blob acquiring unit is configured to segment a blob having a width of a circumscribed rectangle of the blob greater than twice a threshold TW of a width of an individual by equal width according to TW;
segment a blob having a height of a circumscribed rectangle of the blob greater than twice a threshold TH of a height of an individual by equal height according to TH;
delete a blob having an area smaller than a predetermined threshold, wherein the blob is acquired after the segmenting.

6. The device according to claim 5, wherein the target blob acquiring unit is further configured to combine two blobs having a centre-of-mass horizontal distance not exceeding TW and a centre-of-mass longitudinal distance not exceeding TH;
divide a width of a circumscribed rectangle of each acquired combined blob by TW and then perform rounding to acquire a first value NW, and divide the height of the circumscribed rectangle by TH and then perform rounding to acquire a second value NH;
determine whether NW and NH of each combined blob are smaller than 2 respectively; if greater than 2, then split the combined blob; if smaller than 2, then retain the combined blob; and
repeat the three foregoing steps until all blobs are combined.

7. The device according to claim 5, further comprising:
an updating unit, configured to update a background image and a background amplitude with different updating rate coefficients according to an image of a current frame.

8. The device according to claim 5, wherein the pedestrian number counting unit is configured to track each target blob in the detection area using a nearest proximity matching algorithm, wherein a cost function applied by the nearest proximity matching algorithm is a Euclidean distance.

9. A pedestrian tracking and counting method for a near-front top-view monitoring video, comprising:
acquiring a video image under a current monitoring scene;
comparing the video image with a background image, and when it is determined that the video image is a foreground image, segmenting and combining each blob in the foreground image to acquire a target blob representing an individual pedestrian;
performing tracking and counting according to a centre-of-mass coordinate of each target blob in a detection area to acquire the number of pedestrians under the current monitoring scene,
wherein combining each blob in the foreground image comprises:
combining two blobs having a centre-of-mass horizontal distance not exceeding a threshold TW of a width of an individual and a centre-of-mass longitudinal distance not exceeding a threshold TH of a height of an individual;
dividing a width of a circumscribed rectangle of each acquired combined blob by TW and then performing rounding to acquire a first value NW, and dividing a height of the circumscribed rectangle by TH and then performing rounding to acquire a second value NH;
determining whether NW and NH of each combined blob are smaller than 2 respectively; if greater than 2, then splitting the combined blob; if smaller than 2, then retaining the combined blob; and
repeating the three foregoing steps until all blobs are combined.

10. The method according to claim 9, after it is determined that the video image is a foreground image, the method further comprising:
updating a background image and a background amplitude with different updating rate coefficients according to an image of a current frame.

11. The method according to claim 9, wherein performing tracking comprises:
tracking each target blob in the detection area using a nearest proximity matching algorithm, wherein a cost function applied by the nearest proximity matching algorithm is a Euclidean distance.

12. A pedestrian tracking and counting device for a near-front top-view monitoring video, comprising:
a video image acquiring unit, configured to acquire a video image under a current monitoring scene;
a target blob acquiring unit, configured to compare the video image with a background image, and to, when it is determined that the video image is a foreground image, segment and combine each blob in the foreground image to acquire a target blob representing an individual pedestrian; and
a pedestrian number counting unit, configured to perform tracking and counting according to a centre-of-mass coordinate of each target blob in a detection area to acquire the number of pedestrians under the current monitoring scene,
wherein the target blob acquiring unit is further configured to combine two blobs having a centre-of-mass horizontal distance not exceeding a threshold TW of a width of an individual and a centre-of-mass longitudinal distance not exceeding a threshold TH of a height of an individual;
divide a width of a circumscribed rectangle of each acquired combined blob by TW and then perform rounding to acquire a first value NW, and divide the height of the circumscribed rectangle by TH and then perform rounding to acquire a second value NH;
determine whether NW and NH of each combined blob are smaller than 2 respectively; if greater than 2, then split the combined blob; if smaller than 2, then retain the combined blob; and
repeat the three foregoing steps until all blobs are combined.

13. The device according to claim 12, further comprising:
an updating unit, configured to update a background image and a background amplitude with different updating rate coefficients according to an image of a current frame.

14. The device according to claim 12, wherein the pedestrian number counting unit is configured to track each target blob in the detection area using a nearest proximity matching algorithm, wherein a cost function applied by the nearest proximity matching algorithm is a Euclidean distance.