-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__init__.py
46 lines (32 loc) · 1.13 KB
/
__init__.py
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
41
42
43
44
45
46
from __future__ import absolute_import
import numpy as np
import time
from PIL import Image
from ..utils.viz import show_frame
class Tracker(object):
def __init__(self, name, is_deterministic=False):
self.name = name
self.is_deterministic = is_deterministic
def init(self, image, box):
raise NotImplementedError()
def update(self, image):
raise NotImplementedError()
def track(self, img_files, box, visualize=False):
frame_num = len(img_files)
boxes = np.zeros((frame_num, 4))
boxes[0] = box
times = np.zeros(frame_num)
for f, img_file in enumerate(img_files):
image = Image.open(img_file)
if not image.mode == 'RGB':
image = image.convert('RGB')
start_time = time.time()
if f == 0:
self.init(image, box)
else:
boxes[f, :] = self.update(image)
times[f] = time.time() - start_time
if visualize:
show_frame(image, boxes[f, :])
return boxes, times
from .identity_tracker import IdentityTracker