Update app.py
Browse files
app.py
CHANGED
|
@@ -159,6 +159,7 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits', blur_data
|
|
| 159 |
depth_frames = []
|
| 160 |
orig_frames = []
|
| 161 |
backup_frames = []
|
|
|
|
| 162 |
thumbnail_old = []
|
| 163 |
|
| 164 |
while raw_video.isOpened():
|
|
@@ -191,12 +192,12 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits', blur_data
|
|
| 191 |
#white_lo = np.array([250,250,250])
|
| 192 |
#white_hi = np.array([255,255,255])
|
| 193 |
# mask image to only select white
|
| 194 |
-
mask = cv2.inRange(depth_gray[0:int(depth_gray.shape[0]/
|
| 195 |
# change image to black where we found white
|
| 196 |
-
depth_gray[0:int(depth_gray.shape[0]/
|
| 197 |
|
| 198 |
-
mask = cv2.inRange(depth_gray[int(depth_gray.shape[0]/
|
| 199 |
-
depth_gray[int(depth_gray.shape[0]/
|
| 200 |
|
| 201 |
depth_color = cv2.cvtColor(depth_gray, cv2.COLOR_GRAY2BGR)
|
| 202 |
# split_region = np.ones((frame_height, margin_width, 3), dtype=np.uint8) * 255
|
|
@@ -222,22 +223,6 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits', blur_data
|
|
| 222 |
thumbnail_old = thumbnail
|
| 223 |
|
| 224 |
blur_frame = blur_image(raw_frame, depth_color, blur_data)
|
| 225 |
-
|
| 226 |
-
# encoding depth within original video
|
| 227 |
-
dd = 5
|
| 228 |
-
cd = 255 / dd
|
| 229 |
-
mask = cv2.inRange(blur_frame, 255, 255)
|
| 230 |
-
blur_frame[mask>0] = np.array([254,254,254])
|
| 231 |
-
blur_frame = (np.floor(blur_frame / dd) * dd).astype(np.uint8)
|
| 232 |
-
|
| 233 |
-
depth_comp = np.round(depth_gray / 2).astype(np.uint8) # 0-96
|
| 234 |
-
depth_r = np.floor(depth_comp / cd).astype(np.uint8)
|
| 235 |
-
depth_g = np.floor((depth_comp - depth_r * cd) / cd).astype(np.uint8)
|
| 236 |
-
depth_b = depth_comp - depth_r * cd - depth_g * cd
|
| 237 |
-
|
| 238 |
-
blur_frame[:,:,0] = blur_frame[:,:,0] + depth_r
|
| 239 |
-
blur_frame[:,:,1] = blur_frame[:,:,1] + depth_g
|
| 240 |
-
blur_frame[:,:,2] = blur_frame[:,:,2] + depth_b
|
| 241 |
|
| 242 |
cv2.imwrite(f"f{count}.jpg", blur_frame)
|
| 243 |
orig_frames.append(f"f{count}.jpg")
|
|
@@ -248,6 +233,9 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits', blur_data
|
|
| 248 |
cv2.imwrite(f"f{count}_dmap.jpg", depth_color)
|
| 249 |
depth_frames.append(f"f{count}_dmap.jpg")
|
| 250 |
|
|
|
|
|
|
|
|
|
|
| 251 |
depth_gray = seg_frame(depth_gray, o, b) + 128
|
| 252 |
#print(depth_gray[depth_gray>128]-128)
|
| 253 |
|
|
@@ -255,7 +243,7 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits', blur_data
|
|
| 255 |
masks.append(f"f{count}_mask.jpg")
|
| 256 |
count += 1
|
| 257 |
|
| 258 |
-
final_vid = create_video(
|
| 259 |
depth_vid = create_video(depth_frames, frame_rate, "depth")
|
| 260 |
|
| 261 |
final_zip = zip_files(orig_frames, depth_frames)
|
|
|
|
| 159 |
depth_frames = []
|
| 160 |
orig_frames = []
|
| 161 |
backup_frames = []
|
| 162 |
+
comb_frames = []
|
| 163 |
thumbnail_old = []
|
| 164 |
|
| 165 |
while raw_video.isOpened():
|
|
|
|
| 192 |
#white_lo = np.array([250,250,250])
|
| 193 |
#white_hi = np.array([255,255,255])
|
| 194 |
# mask image to only select white
|
| 195 |
+
mask = cv2.inRange(depth_gray[0:int(depth_gray.shape[0]/7*6)-1, 0:depth_gray.shape[1]], 250, 255)
|
| 196 |
# change image to black where we found white
|
| 197 |
+
depth_gray[0:int(depth_gray.shape[0]/7*6)-1, 0:depth_gray.shape[1]][mask>0] = 0
|
| 198 |
|
| 199 |
+
mask = cv2.inRange(depth_gray[int(depth_gray.shape[0]/7*6):depth_gray.shape[0], 0:depth_gray.shape[1]], 180, 255)
|
| 200 |
+
depth_gray[int(depth_gray.shape[0]/7*6):depth_gray.shape[0], 0:depth_gray.shape[1]][mask>0] = 180
|
| 201 |
|
| 202 |
depth_color = cv2.cvtColor(depth_gray, cv2.COLOR_GRAY2BGR)
|
| 203 |
# split_region = np.ones((frame_height, margin_width, 3), dtype=np.uint8) * 255
|
|
|
|
| 223 |
thumbnail_old = thumbnail
|
| 224 |
|
| 225 |
blur_frame = blur_image(raw_frame, depth_color, blur_data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
cv2.imwrite(f"f{count}.jpg", blur_frame)
|
| 228 |
orig_frames.append(f"f{count}.jpg")
|
|
|
|
| 233 |
cv2.imwrite(f"f{count}_dmap.jpg", depth_color)
|
| 234 |
depth_frames.append(f"f{count}_dmap.jpg")
|
| 235 |
|
| 236 |
+
comb_frames.append(f"f{count}.jpg")
|
| 237 |
+
comb_frames.append(f"f{count}_dmap.jpg")
|
| 238 |
+
|
| 239 |
depth_gray = seg_frame(depth_gray, o, b) + 128
|
| 240 |
#print(depth_gray[depth_gray>128]-128)
|
| 241 |
|
|
|
|
| 243 |
masks.append(f"f{count}_mask.jpg")
|
| 244 |
count += 1
|
| 245 |
|
| 246 |
+
final_vid = create_video(comb_frames, frame_rate, "orig")
|
| 247 |
depth_vid = create_video(depth_frames, frame_rate, "depth")
|
| 248 |
|
| 249 |
final_zip = zip_files(orig_frames, depth_frames)
|