-
Notifications
You must be signed in to change notification settings - Fork 0
/
vot_run_CRT.py
44 lines (30 loc) · 876 Bytes
/
vot_run_CRT.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
import vot
import sys
import time
import numpy
import collections
import cv2
import simgeo
import tracker
class VOT_CRT_Wrapper(object):
def __init__(self, image, region):
self._tracker = tracker.ConvRegTracker()
_init_rect = simgeo.Rect(region.x, region.y, region.width, region.height)
self._tracker.init(image, _init_rect)
def track(self, image):
res_rect = self._tracker.track(image)
return vot.Rectangle(res_rect.x, res_rect.y, res_rect.w, res_rect.h)
handle = vot.VOT("rectangle")
selection = handle.region()
imagefile = handle.frame()
if not imagefile:
sys.exit(0)
image = cv2.imread(imagefile)
trk = VOT_CRT_Wrapper(image, selection)
while True:
imagefile = handle.frame()
if not imagefile:
break
image = cv2.imread(imagefile)
region = trk.track(image)
handle.report(region)