-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtracker.py
More file actions
27 lines (22 loc) · 795 Bytes
/
tracker.py
File metadata and controls
27 lines (22 loc) · 795 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
import cv2
class vehicle_tracker(object):
"""docstring for vehicle_tracker"""
def __init__(self):
'''
初始化tracker
追踪器默认为KCF
边框颜色默认为红
'''
super(vehicle_tracker, self).__init__()
self.tracker = cv2.TrackerKCF_create()
def init_tracker(self, first_frame, bounding_box):
self.tracker.init(first_frame, bounding_box)
def tracking(self, target_frame):
'''
追踪物体,并返回边框
first_frame为第一帧的帧数号
bounding_box为需要追踪物体的边框
格式为(x1,y1,x2,y2)
targer_frame: frame that wanted to be updated
'''
return self.tracker.update(target_frame)