Browse Source

Add Count people

master
lheimbs 4 years ago
parent
commit
fb7560d92e
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      camera/video_presence.py

+ 8
- 2
camera/video_presence.py View File

now = '' now = ''
framecounter = 0 framecounter = 0
trackeron = 0 trackeron = 0
people_count_total = 0


while True: while True:
people_count_per_frame = 0
frame = vs.read() frame = vs.read()
frame = frame if args.get("video", None) is None else frame[1] frame = frame if args.get("video", None) is None else frame[1]
# if the frame can not be grabbed, then we have reached the end of the video # if the frame can not be grabbed, then we have reached the end of the video
for i in np.arange(0, detections.shape[2]): for i in np.arange(0, detections.shape[2]):
confidence = detections[0, 0, i, 2] confidence = detections[0, 0, i, 2]


confidence_level = 0.7
confidence_level = 0.8


if confidence > confidence_level: if confidence > confidence_level:
people_count_per_frame+=1
people_count_total+=1
# extract the index of the class label from the `detections`, then compute the (x, y)-coordinates of # extract the index of the class label from the `detections`, then compute the (x, y)-coordinates of
# the bounding box for the object # the bounding box for the object
idx = int(detections[0, 0, i, 1]) idx = int(detections[0, 0, i, 1])




# check to see if we are currently tracking an object, if so, ignore other boxes # check to see if we are currently tracking an object, if so, ignore other boxes
# this code is relevant if we want to identify particular persons (section 2 of this tutorial)
# this code is relevant if we want to identify particular persons
if initBB2 is not None: if initBB2 is not None:


# grab the new bounding box coordinates of the object # grab the new bounding box coordinates of the object
info = [ info = [
("Success", "Yes" if success else "No"), ("Success", "Yes" if success else "No"),
("FPS", "{:.2f}".format(fps.fps())), ("FPS", "{:.2f}".format(fps.fps())),
("People Frame", "{}".format(people_count_per_frame)),
("People Total", "{}".format(people_count_total))
] ]


# loop over the info tuples and draw them on our frame # loop over the info tuples and draw them on our frame

Loading…
Cancel
Save