freealise commited on
Commit
23a9f49
·
verified ·
1 Parent(s): caebb59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -195,8 +195,8 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits', blur_data
195
  # change image to black where we found white
196
  depth_gray[0:int(depth_gray.shape[0]/8*7)-1, 0:depth_gray.shape[1]][mask>0] = 0
197
 
198
- mask = cv2.inRange(depth_gray[int(depth_gray.shape[0]/8*7):depth_gray.shape[0], 0:depth_gray.shape[1]], 125, 255)
199
- depth_gray[int(depth_gray.shape[0]/8*7):depth_gray.shape[0], 0:depth_gray.shape[1]][mask>0] = 125
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
@@ -225,12 +225,18 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits', blur_data
225
 
226
  # encoding depth within original video
227
  dd = 5
 
 
 
228
  blur_frame = (np.floor(blur_frame / dd) * dd).astype(np.uint8)
229
- depth_r = np.floor(depth_gray / dd).astype(np.uint8)
230
- # may use green channel for 16 levels of opacity
231
- depth_b = depth_gray - depth_r * dd
 
 
 
232
  blur_frame[:,:,0] = blur_frame[:,:,0] + depth_r
233
- # blur_frame[:,:,1] = blur_frame[:,:,1] + opacity_g
234
  blur_frame[:,:,2] = blur_frame[:,:,2] + depth_b
235
 
236
  cv2.imwrite(f"f{count}.jpg", blur_frame)
 
195
  # change image to black where we found white
196
  depth_gray[0:int(depth_gray.shape[0]/8*7)-1, 0:depth_gray.shape[1]][mask>0] = 0
197
 
198
+ mask = cv2.inRange(depth_gray[int(depth_gray.shape[0]/8*7):depth_gray.shape[0], 0:depth_gray.shape[1]], 192, 255)
199
+ depth_gray[int(depth_gray.shape[0]/8*7):depth_gray.shape[0], 0:depth_gray.shape[1]][mask>0] = 192
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
 
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)