nikkar commited on
Commit
bce322b
·
verified ·
1 Parent(s): 2e68677

Update visualizer.py

Browse files
Files changed (1) hide show
  1. 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
- visibile = True
274
- if visibility is not None:
275
- visibile = visibility[0, t, i]
276
- if coord[0] != 0 and coord[1] != 0:
277
- if not compensate_for_camera_motion or (
278
- compensate_for_camera_motion and segm_mask[i] > 0
279
- ):
280
- # img = draw_circle(
281
- # img,
282
- # coord=coord,
283
- # radius=int(self.linewidth * 2),
284
- # color=vector_colors[t, i].astype(int),
285
- # visible=visibile,
286
- # color_alpha=color_alpha,
287
- # )
288
-
289
- # coord_ = coord[t,i]
290
- # draw a red cross
291
- # if gt_tracks[0] > 0 and gt_tracks[1] > 0:
292
- if visibile:
293
- length = self.linewidth * 3
294
- coord_y = ((coord[0]) + length, (coord[1]) + length)
295
- coord_x = ((coord[0]) - length, (coord[1]) - length)
296
- rgb = draw_line(
297
- img,
298
- coord_y,
299
- coord_x,
300
- vector_colors[t, i].astype(int),
301
- self.linewidth,
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