freealise commited on
Commit
e898a85
1 Parent(s): 4e6cc23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -482,17 +482,21 @@ def apply_mask(d, b):
482
  d["background"][mask==255] = (0,0,0,0)
483
  mask = cv2.inRange(d["background"], np.array([0,0,0,0]), np.array([0,0,0,0]))
484
 
 
 
 
 
 
485
  for k, mk in enumerate(masks):
486
  if k != frame_selected and k < len(depths):
487
  masks[k] = cv2.imread(depths[k]).astype(np.uint8)
488
  masks[k][dmask<255] = (0,0,0)
489
-
490
- ksize = int(np.sqrt(np.sum(mask) / 255))
491
- if ksize/2 - int(ksize/2) == 0:
492
- ksize = ksize + 1
493
 
494
  frame = cv2.imread(frames[frame_selected], cv2.IMREAD_UNCHANGED).astype(np.uint8)
495
- dmask = cv2.GaussianBlur(dmask, (ksize,ksize), 0)
496
  frame[:, :, 3] = 255 - dmask
497
  cv2.imwrite(frames[frame_selected], frame)
498
 
 
482
  d["background"][mask==255] = (0,0,0,0)
483
  mask = cv2.inRange(d["background"], np.array([0,0,0,0]), np.array([0,0,0,0]))
484
 
485
+ ksize = int(np.sqrt(np.sum(mask) / 255))
486
+ if ksize/2 - int(ksize/2) == 0:
487
+ ksize = ksize + 1
488
+ dmask = cv2.GaussianBlur(dmask, (ksize,ksize), 0)
489
+
490
  for k, mk in enumerate(masks):
491
  if k != frame_selected and k < len(depths):
492
  masks[k] = cv2.imread(depths[k]).astype(np.uint8)
493
  masks[k][dmask<255] = (0,0,0)
494
+ cv2.imwrite(depths[k], masks[k])
495
+ frame = cv2.imread(frames[k], cv2.IMREAD_UNCHANGED).astype(np.uint8)
496
+ frame[:, :, 3] = dmask
497
+ cv2.imwrite(frames[k], frame)
498
 
499
  frame = cv2.imread(frames[frame_selected], cv2.IMREAD_UNCHANGED).astype(np.uint8)
 
500
  frame[:, :, 3] = 255 - dmask
501
  cv2.imwrite(frames[frame_selected], frame)
502