-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrackContainer.py
More file actions
40 lines (35 loc) · 859 Bytes
/
trackContainer.py
File metadata and controls
40 lines (35 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from __future__ import print_function
import sys
import cv2
from random import randint
import imutils
from imutils.object_detection import non_max_suppression
import numpy as np
import people
class container():
def __init__(self):
self.trackers = {}
self.people = {}
def add(self, tracker, tnum, frame, bbox, color):
tracker.init(frame, bbox)
p = people.person(tnum, bbox, color)
self.trackers[tnum] = tracker
self.people[tnum] = p
return p
def update(self, frame):
bools = []
bboxes = []
ids = []
peo = []
for k, v in self.trackers.items():
boo, bbox = v.update(frame)
self.people[k].update(bbox)
peo.append(self.people[k])
bools.append(boo)
bboxes.append(bbox)
ids.append(k)
return bools, bboxes, ids, peo
def remove(self, ID):
self.people[ID].deleteSelf()
del self.trackers[ID]
print("done!")