def segment(locs, info, segmentation, kwargs={}, callback=None):
Y = info[0]['Height']
X = info[0]['Width']
n_frames = info[0]['Frames']
n_seg = n_segments(info, segmentation)
bounds = _np.linspace(0, n_frames-1, n_seg+1, dtype=_np.uint32)
segments = _np.zeros((n_seg, Y, X))
if callback is not None:
callback(0)
for i in _trange(n_seg, desc='Generating segments', unit='segments'):
segment_locs = locs[(locs.frame >= bounds[i]) & (locs.frame < bounds[i+1])]
_, segments[i] = render(segment_locs, info, **kwargs)
if callback is not None:
callback(i+1)
return bounds, segments
评论列表
文章目录