Spaces:
Starting
Starting
Update app.py
Browse files
app.py
CHANGED
@@ -114,7 +114,6 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits'):
|
|
114 |
#fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
115 |
#out = cv2.VideoWriter(output_path, fourcc, frame_rate, (output_width, frame_height))
|
116 |
count=0
|
117 |
-
depth_frames_gray = []
|
118 |
depth_frames = []
|
119 |
orig_frames = []
|
120 |
while raw_video.isOpened():
|
@@ -137,7 +136,7 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits'):
|
|
137 |
depth = depth.cpu().numpy().astype(np.uint8)
|
138 |
depth_color = cv2.applyColorMap(depth, cv2.COLORMAP_BONE)
|
139 |
depth_gray = cv2.cvtColor(depth_color, cv2.COLOR_RGBA2GRAY)
|
140 |
-
depth_color = cv2.cvtColor(depth_gray, cv2.
|
141 |
|
142 |
# Remove white border around map:
|
143 |
# define lower and upper limits of white
|
@@ -147,7 +146,6 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits'):
|
|
147 |
mask = cv2.inRange(depth_color, white_lo, white_hi)
|
148 |
# change image to black where we found white
|
149 |
depth_color[mask>0] = (0,0,0)
|
150 |
-
depth_gray = cv2.cvtColor(depth_color, cv2.COLOR_RGB2GRAY)
|
151 |
|
152 |
# split_region = np.ones((frame_height, margin_width, 3), dtype=np.uint8) * 255
|
153 |
# combined_frame = cv2.hconcat([raw_frame, split_region, depth_color])
|
@@ -159,13 +157,11 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits'):
|
|
159 |
cv2.imwrite(f"f{count}.jpg", raw_frame)
|
160 |
orig_frames.append(f"f{count}.jpg")
|
161 |
cv2.imwrite(f"f{count}_dmap.jpg", depth_color)
|
162 |
-
cv2.imwrite(f"f{count}_dmap_gray.jpg", depth_gray)
|
163 |
depth_frames.append(f"f{count}_dmap.jpg")
|
164 |
-
depth_frames_gray.append(f"f{count}_dmap_gray.jpg")
|
165 |
count += 1
|
166 |
|
167 |
final_vid = create_video(depth_frames, frame_rate, "depth")
|
168 |
-
final_zip = zip_files(orig_frames,
|
169 |
raw_video.release()
|
170 |
# out.release()
|
171 |
cv2.destroyAllWindows()
|
|
|
114 |
#fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
115 |
#out = cv2.VideoWriter(output_path, fourcc, frame_rate, (output_width, frame_height))
|
116 |
count=0
|
|
|
117 |
depth_frames = []
|
118 |
orig_frames = []
|
119 |
while raw_video.isOpened():
|
|
|
136 |
depth = depth.cpu().numpy().astype(np.uint8)
|
137 |
depth_color = cv2.applyColorMap(depth, cv2.COLORMAP_BONE)
|
138 |
depth_gray = cv2.cvtColor(depth_color, cv2.COLOR_RGBA2GRAY)
|
139 |
+
depth_color = cv2.cvtColor(depth_gray, cv2.COLOR_GRAY2BGR)
|
140 |
|
141 |
# Remove white border around map:
|
142 |
# define lower and upper limits of white
|
|
|
146 |
mask = cv2.inRange(depth_color, white_lo, white_hi)
|
147 |
# change image to black where we found white
|
148 |
depth_color[mask>0] = (0,0,0)
|
|
|
149 |
|
150 |
# split_region = np.ones((frame_height, margin_width, 3), dtype=np.uint8) * 255
|
151 |
# combined_frame = cv2.hconcat([raw_frame, split_region, depth_color])
|
|
|
157 |
cv2.imwrite(f"f{count}.jpg", raw_frame)
|
158 |
orig_frames.append(f"f{count}.jpg")
|
159 |
cv2.imwrite(f"f{count}_dmap.jpg", depth_color)
|
|
|
160 |
depth_frames.append(f"f{count}_dmap.jpg")
|
|
|
161 |
count += 1
|
162 |
|
163 |
final_vid = create_video(depth_frames, frame_rate, "depth")
|
164 |
+
final_zip = zip_files(orig_frames, depth_frames)
|
165 |
raw_video.release()
|
166 |
# out.release()
|
167 |
cv2.destroyAllWindows()
|