def update(self,frame,events):
falloff = self.falloff
img = frame.img
pts = [denormalize(pt['norm_pos'],frame.img.shape[:-1][::-1],flip_y=True) for pt in events.get('gaze_positions',[]) if pt['confidence']>=self.g_pool.min_data_confidence]
overlay = np.ones(img.shape[:-1],dtype=img.dtype)
# draw recent gaze postions as black dots on an overlay image.
for gaze_point in pts:
try:
overlay[int(gaze_point[1]),int(gaze_point[0])] = 0
except:
pass
out = cv2.distanceTransform(overlay,cv2.DIST_L2, 5)
# fix for opencv binding inconsitency
if type(out)==tuple:
out = out[0]
overlay = 1/(out/falloff+1)
img[:] = np.multiply(img, cv2.cvtColor(overlay,cv2.COLOR_GRAY2RGB), casting="unsafe")
评论列表
文章目录