4
4
import time
5
5
from typing import List , Optional , Tuple , Union
6
6
7
+ import cv2
7
8
import lightning .pytorch as pl
8
9
import matplotlib .pyplot as plt
9
10
import numpy as np
10
11
import pandas as pd
11
12
import torch
12
13
from omegaconf import DictConfig , OmegaConf
13
14
from pytorch_lightning import LightningModule
14
- from skimage .draw import disk
15
15
from torchtyping import TensorType
16
16
from tqdm import tqdm
17
17
from typeguard import typechecked
@@ -690,7 +690,7 @@ def create_labeled_video(
690
690
xs_arr ,
691
691
ys_arr ,
692
692
mask_array = None ,
693
- dotsize = 5 ,
693
+ dotsize = 4 ,
694
694
colormap = "cool" ,
695
695
fps = None ,
696
696
filename = "movie.mp4" ,
@@ -719,14 +719,10 @@ def create_labeled_video(
719
719
colors = make_cmap (n_keypoints , cmap = colormap )
720
720
721
721
nx , ny = clip .size
722
- duration = int (clip .duration - clip .start )
722
+ dur = int (clip .duration - clip .start )
723
723
fps_og = clip .fps
724
724
725
- print (
726
- "Duration of video [s]: {}, recorded with {} fps!" .format (
727
- np .round (duration , 2 ), np .round (fps_og , 2 )
728
- )
729
- )
725
+ print (f"Duration of video [s]: { np .round (dur , 2 )} , recorded at { np .round (fps_og , 2 )} fps!" )
730
726
731
727
# add marker to each frame t, where t is in sec
732
728
def add_marker (get_frame , t ):
@@ -742,8 +738,13 @@ def add_marker(get_frame, t):
742
738
if mask_array [index , bpindex ]:
743
739
xc = min (int (xs_arr [index , bpindex ]), nx - 1 )
744
740
yc = min (int (ys_arr [index , bpindex ]), ny - 1 )
745
- rr , cc = disk (center = (yc , xc ), radius = dotsize , shape = (ny , nx ))
746
- frame [rr , cc , :] = colors [bpindex ]
741
+ frame = cv2 .circle (
742
+ frame ,
743
+ center = (xc , yc ),
744
+ radius = dotsize ,
745
+ color = colors [bpindex ].tolist (),
746
+ thickness = - 1
747
+ )
747
748
return frame
748
749
749
750
clip_marked = clip .fl (add_marker )
0 commit comments