Commit 9162fb2b authored by Mohammed Azzam M.A's avatar Mohammed Azzam M.A

Upload New File

parent a0f9dc62
import numpy as np
self.kf.Q[4:, 4:] *= 0.01
self.ylist.append(zbox[1][0])
else:
self.ylist.append(zbox[1][0])
if len(self.xlist) > 1:
# print(self.xlist)
xstd = statistics.stdev(self.xlist)
ystd = statistics.stdev(self.ylist)
if xstd < self.stdvar and ystd < self.stdvar and len(self.xlist) >= self.length :
self.dynamicstste = 0
else:
self.dynamicstste = 1
if len(self.ylist) >= int(config.fps):
if self.ylist[-1] > self.ylist[-int(config.fps)]:
self.reversevar = 1
elif self.ylist[-1] < self.ylist[-int(config.fps)]:
self.reversevar = -1
else:
self.reversevar = 0
# print('0',self.ylist[-int(config.fps)],'-1',self.ylist[-1])
return np.concatenate((convert_x_to_bbox(zbox)[0],[self.dynamicstste],[self.reversevar]))
def convert_bbox_to_z(bbox):
"""
Takes a bounding box in the form [x1,y1,x2,y2] and returns z in the form
[x,y,s,r] where x,y is the centre of the box and s is the scale/area and r is
the aspect ratio
"""
w = bbox[2] - bbox[0]
h = bbox[3] - bbox[1]
x = bbox[0] + w/2.
y = bbox[1] + h/2.
s = w * h
r = w / float(h)
return np.array([x, y, s, r]).reshape((4, 1))
def convert_x_to_bbox(x,score=None):
"""
Takes a bounding box in the centre form [x,y,s,r] and returns it in the form
[x1,y1,x2,y2] where x1,y1 is the top left and x2,y2 is the bottom right
"""
w = np.sqrt(x[2] * x[3])
h = x[2] / w
if score == None:
return np.array([x[0]-w/2., x[1]-h/2., x[0]+w/2., x[1]+h/2.]).reshape((1, 4))
else:
return np.array([x[0]-w/2., x[1]-h/2., x[0]+w/2., x[1]+h/2., score]).reshape((1, 5))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment