Spaces:
Running
on
L40S
Running
on
L40S
Update utils/dc_utils.py
Browse files- utils/dc_utils.py +2 -2
utils/dc_utils.py
CHANGED
@@ -71,7 +71,7 @@ def read_video_frames(video_path, process_length, target_fps=-1, max_res=-1):
|
|
71 |
return frames, fps
|
72 |
|
73 |
|
74 |
-
def save_video(frames, output_video_path, fps=10, is_depths=False):
|
75 |
writer = imageio.get_writer(output_video_path, fps=fps, macro_block_size=1, codec='libx264', ffmpeg_params=['-crf', '18'])
|
76 |
if is_depths:
|
77 |
colormap = np.array(cm.get_cmap("inferno").colors)
|
@@ -79,7 +79,7 @@ def save_video(frames, output_video_path, fps=10, is_depths=False):
|
|
79 |
for i in range(frames.shape[0]):
|
80 |
depth = frames[i]
|
81 |
depth_norm = ((depth - d_min) / (d_max - d_min) * 255).astype(np.uint8)
|
82 |
-
depth_vis = (colormap[depth_norm] * 255).astype(np.uint8)
|
83 |
writer.append_data(depth_vis)
|
84 |
else:
|
85 |
for i in range(frames.shape[0]):
|
|
|
71 |
return frames, fps
|
72 |
|
73 |
|
74 |
+
def save_video(frames, output_video_path, fps=10, is_depths=False, grayscale=False):
|
75 |
writer = imageio.get_writer(output_video_path, fps=fps, macro_block_size=1, codec='libx264', ffmpeg_params=['-crf', '18'])
|
76 |
if is_depths:
|
77 |
colormap = np.array(cm.get_cmap("inferno").colors)
|
|
|
79 |
for i in range(frames.shape[0]):
|
80 |
depth = frames[i]
|
81 |
depth_norm = ((depth - d_min) / (d_max - d_min) * 255).astype(np.uint8)
|
82 |
+
depth_vis = (colormap[depth_norm] * 255).astype(np.uint8) if not grayscale else depth_norm
|
83 |
writer.append_data(depth_vis)
|
84 |
else:
|
85 |
for i in range(frames.shape[0]):
|