freealise commited on
Commit
352cf00
1 Parent(s): 2658ede

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -14
app.py CHANGED
@@ -484,14 +484,9 @@ def apply_mask(d, b):
484
  dmask = cv2.dilate(mask, dilation)
485
  dmask_b = cv2.GaussianBlur(dmask, (b,b), 0)
486
 
487
- d["background"][mask==255] = (0,0,0,0)
488
- mask = cv2.inRange(d["background"], np.array([0,0,0,0]), np.array([0,0,0,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_b
497
  cv2.imwrite(frames[k], frame)
@@ -501,10 +496,10 @@ def apply_mask(d, b):
501
  cv2.imwrite(frames[frame_selected], frame)
502
 
503
  masks[frame_selected] = mask #d["background"]
504
- #cv2.imwrite(depths[frame_selected], masks[frame_selected])
505
  return masks[frame_selected], depths, frames
506
 
507
  def draw_mask(l, t, v, d, evt: gr.EventData):
 
508
  global params
509
  global frame_selected
510
  global masks
@@ -521,7 +516,7 @@ def draw_mask(l, t, v, d, evt: gr.EventData):
521
 
522
  if len(edge) == 0 or params["fnum"] != frame_selected or params["l"] != l:
523
  if len(edge) > 0:
524
- d["background"] = cv2.imread(masks[frame_selected]).astype(np.uint8)
525
 
526
  bg = cv2.cvtColor(d["background"], cv2.COLOR_RGBA2GRAY)
527
 
@@ -643,7 +638,7 @@ async(c, o, b, p, d, n, m)=>{
643
  let mesh = q[i];
644
  mesh.dispose(false, true);
645
  }
646
- BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].material.needDepthPrePass = true;
647
  BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].alphaIndex = o_.length-j;
648
  BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].scaling.z = -1;
649
  BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].applyDisplacementMap(m[o_[j]].url, 0, 255, function(m){try{alert(BABYLON.Engine.Version);}catch(e){alert(e);}}, null, null, true, function(e){alert(e);});
@@ -676,11 +671,7 @@ async(c, o, b, p, d, n, m)=>{
676
  o_[j] = parseInt(o_[j]);
677
  alert(o_[j]);
678
  document.getElementById("iframe3D").contentDocument.getElementById("bgimage").value += p[o_[j]].image.url + ",";
679
- if (o_[j] == n) {
680
- document.getElementById("iframe3D").contentDocument.getElementById("bgdepth").value += d.background.url + ",";
681
- } else {
682
- document.getElementById("iframe3D").contentDocument.getElementById("bgdepth").value += m[o_[j]].url + ",";
683
- }
684
  }
685
  }
686
  toggleDisplay("model");
 
484
  dmask = cv2.dilate(mask, dilation)
485
  dmask_b = cv2.GaussianBlur(dmask, (b,b), 0)
486
 
 
 
 
487
  for k, mk in enumerate(masks):
488
  if k != frame_selected and k < len(depths):
489
+ masks[k][dmask<255] = 0
 
 
490
  frame = cv2.imread(frames[k], cv2.IMREAD_UNCHANGED).astype(np.uint8)
491
  frame[:, :, 3] = dmask_b
492
  cv2.imwrite(frames[k], frame)
 
496
  cv2.imwrite(frames[frame_selected], frame)
497
 
498
  masks[frame_selected] = mask #d["background"]
 
499
  return masks[frame_selected], depths, frames
500
 
501
  def draw_mask(l, t, v, d, evt: gr.EventData):
502
+ global depths
503
  global params
504
  global frame_selected
505
  global masks
 
516
 
517
  if len(edge) == 0 or params["fnum"] != frame_selected or params["l"] != l:
518
  if len(edge) > 0:
519
+ d["background"] = cv2.imread(depths[frame_selected]).astype(np.uint8)
520
 
521
  bg = cv2.cvtColor(d["background"], cv2.COLOR_RGBA2GRAY)
522
 
 
638
  let mesh = q[i];
639
  mesh.dispose(false, true);
640
  }
641
+ //BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].material.needDepthPrePass = true;
642
  BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].alphaIndex = o_.length-j;
643
  BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].scaling.z = -1;
644
  BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].applyDisplacementMap(m[o_[j]].url, 0, 255, function(m){try{alert(BABYLON.Engine.Version);}catch(e){alert(e);}}, null, null, true, function(e){alert(e);});
 
671
  o_[j] = parseInt(o_[j]);
672
  alert(o_[j]);
673
  document.getElementById("iframe3D").contentDocument.getElementById("bgimage").value += p[o_[j]].image.url + ",";
674
+ document.getElementById("iframe3D").contentDocument.getElementById("bgdepth").value += m[o_[j]].url + ",";
 
 
 
 
675
  }
676
  }
677
  toggleDisplay("model");