freealise commited on
Commit
ef2485c
1 Parent(s): 227fb6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -202,11 +202,17 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits', remove_bg
202
  mask_bg = cv2.inRange(diff_d, np.array([0,0,0]), np.array([16,16,16]))
203
  mask_no_shadow = cv2.inRange(diff_c, np.array([0,0,0]), np.array([16,16,16]))
204
  mask_shadow = cv2.bitwise_not(mask_no_shadow)
 
 
 
205
 
206
  m = cv2.inRange(raw_frame, np.array([255,255,255]), np.array([255,255,255]))
207
  raw_frame[m>0] = (239,239,239)
208
- raw_frame[cv2.bitwise_and(mask_shadow, mask_bg)>0] = (raw_frame[cv2.bitwise_and(mask_shadow, mask_bg)>0] / 17 + 240).astype(np.uint8)
209
- raw_frame[cv2.bitwise_and(mask_no_shadow, mask_bg)>0] = (255,255,255)
 
 
 
210
 
211
  cv2.imwrite(f"f{count}.png", raw_frame)
212
  orig_frames.append(f"f{count}.png")
 
202
  mask_bg = cv2.inRange(diff_d, np.array([0,0,0]), np.array([16,16,16]))
203
  mask_no_shadow = cv2.inRange(diff_c, np.array([0,0,0]), np.array([16,16,16]))
204
  mask_shadow = cv2.bitwise_not(mask_no_shadow)
205
+
206
+ backSub = cv2.createBackgroundSubtractorMOG2()
207
+ fgMask = backSub.apply(raw_frame)
208
 
209
  m = cv2.inRange(raw_frame, np.array([255,255,255]), np.array([255,255,255]))
210
  raw_frame[m>0] = (239,239,239)
211
+ #raw_frame[cv2.bitwise_and(mask_shadow, mask_bg)>0] = (raw_frame[cv2.bitwise_and(mask_shadow, mask_bg)>0] / 17 + 240).astype(np.uint8)
212
+ #raw_frame[cv2.bitwise_and(mask_no_shadow, mask_bg)>0] = (255,255,255)
213
+ shadowMask = cv2.inRange(fgMask, np.array([1,1,1]), np.array([254,254,254]))
214
+ raw_frame[shadowMask>0] = (raw_frame[shadowMask>0] / 17 + 240).astype(np.uint8)
215
+ raw_frame[fgMask==0] = (255,255,255)
216
 
217
  cv2.imwrite(f"f{count}.png", raw_frame)
218
  orig_frames.append(f"f{count}.png")