Update visualizer.py
Browse files- visualizer.py +30 -39
visualizer.py
CHANGED
@@ -270,45 +270,36 @@ class Visualizer:
|
|
270 |
img = Image.fromarray(np.uint8(res_video[t]))
|
271 |
for i in range(N):
|
272 |
coord = (tracks[t, i, 0], tracks[t, i, 1])
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
if coord[0]
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
coord_y = ((coord[0]) - length, (coord[1]) + length)
|
304 |
-
coord_x = ((coord[0]) + length, (coord[1]) - length)
|
305 |
-
rgb = draw_line(
|
306 |
-
img,
|
307 |
-
coord_y,
|
308 |
-
coord_x,
|
309 |
-
vector_colors[t, i].astype(int),
|
310 |
-
self.linewidth,
|
311 |
-
)
|
312 |
res_video[t] = np.array(img)
|
313 |
|
314 |
# construct the final rgb sequence
|
|
|
270 |
img = Image.fromarray(np.uint8(res_video[t]))
|
271 |
for i in range(N):
|
272 |
coord = (tracks[t, i, 0], tracks[t, i, 1])
|
273 |
+
visible = True if visibility is None else bool(visibility[0, t, i])
|
274 |
+
|
275 |
+
# Skip invalid coordinates
|
276 |
+
if not (0 <= coord[0] < W and 0 <= coord[1] < H):
|
277 |
+
continue
|
278 |
+
|
279 |
+
if visible and (not compensate_for_camera_motion or (
|
280 |
+
compensate_for_camera_motion and segm_mask is not None and segm_mask[i] > 0
|
281 |
+
)):
|
282 |
+
length = self.linewidth * 3
|
283 |
+
# Draw cross with anti-aliasing effect
|
284 |
+
for offset in [-0.5, 0, 0.5]:
|
285 |
+
coord_y = (coord[0] + length + offset, coord[1] + length + offset)
|
286 |
+
coord_x = (coord[0] - length + offset, coord[1] - length + offset)
|
287 |
+
rgb = draw_line(
|
288 |
+
img,
|
289 |
+
coord_y,
|
290 |
+
coord_x,
|
291 |
+
vector_colors[t, i].astype(int),
|
292 |
+
self.linewidth,
|
293 |
+
)
|
294 |
+
coord_y = (coord[0] - length + offset, coord[1] + length + offset)
|
295 |
+
coord_x = (coord[0] + length + offset, coord[1] - length + offset)
|
296 |
+
rgb = draw_line(
|
297 |
+
img,
|
298 |
+
coord_y,
|
299 |
+
coord_x,
|
300 |
+
vector_colors[t, i].astype(int),
|
301 |
+
self.linewidth,
|
302 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
res_video[t] = np.array(img)
|
304 |
|
305 |
# construct the final rgb sequence
|