freealise commited on
Commit
eb3216e
·
verified ·
1 Parent(s): 2c7bac7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -3
app.py CHANGED
@@ -637,7 +637,7 @@ async(c, o, p, d, n, m)=>{
637
  mesh.dispose(false, true);
638
  }
639
  var dome = [];
640
- for (var j=0; j<o_.length; j++) {
641
  o_[j] = parseInt(o_[j]);
642
  dome[j] = new BABYLON.PhotoDome("dome"+j, p[o_[j]].image.url,
643
  {
@@ -663,7 +663,37 @@ async(c, o, p, d, n, m)=>{
663
  BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].position.x = coords[o_[j]].lng;
664
  BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].rotation.y = coords[o_[j]].heading / 180 * Math.PI;
665
  BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].rotation.z = -coords[o_[j]].pitch / 180 * Math.PI;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
666
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
667
 
668
  window.md = false;
669
  window.r_old = 1.0;
@@ -676,7 +706,6 @@ async(c, o, p, d, n, m)=>{
676
  window.yold = 0;
677
  window.buffer = null;
678
  window.ctx = null;
679
- window.video = document.getElementById("depth_video").getElementsByTagName("video")[0];
680
 
681
  document.getElementById("model3D").getElementsByTagName("canvas")[0].addEventListener('pointermove', function(evt) {
682
  if (md === true) {
@@ -1046,7 +1075,7 @@ with gr.Blocks(css=css, js=js, head=head) as demo:
1046
 
1047
  with gr.Column():
1048
  model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl"), ("giant", "vitg")], type="value", value="vits", label='Model Type')
1049
- processed_video = gr.Video(label="Output Video", format="mp4", interactive=False)
1050
  processed_zip = gr.File(label="Output Archive", interactive=False)
1051
  depth_video = gr.Video(label="Depth Video", format="mp4", elem_id="depth_video", interactive=False, visible=False)
1052
  result = gr.Model3D(label="3D Mesh", clear_color=[0.5, 0.5, 0.5, 0.0], camera_position=[0, 90, 0], zoom_speed=2.0, pan_speed=2.0, interactive=True, elem_id="model3D")
 
637
  mesh.dispose(false, true);
638
  }
639
  var dome = [];
640
+ /*for (var j=0; j<o_.length; j++) {
641
  o_[j] = parseInt(o_[j]);
642
  dome[j] = new BABYLON.PhotoDome("dome"+j, p[o_[j]].image.url,
643
  {
 
663
  BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].position.x = coords[o_[j]].lng;
664
  BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].rotation.y = coords[o_[j]].heading / 180 * Math.PI;
665
  BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].rotation.z = -coords[o_[j]].pitch / 180 * Math.PI;
666
+ }*/
667
+ const videoDome = new BABYLON.VideoDome(
668
+ "videoDome",
669
+ [document.getElementById("output_video").getElementsByTagName("video")[0].src],
670
+ {
671
+ resolution: 16,
672
+ size: 512
673
+ clickToPlay: false,
674
+ autoPlay: false,
675
+ poster: 'https://freeali.se/assets/images/1x1.png',
676
+ }, BABYLON.Engine.LastCreatedScene
677
+ );
678
+ var q = BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-2]._children;
679
+ for (i = 0; i < q.length; i++) {
680
+ let mesh = q[i];
681
+ mesh.dispose(false, true);
682
  }
683
+ BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].scaling.z = -1;
684
+ BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].material.emissiveTexture = videoDome.videoTexture;
685
+ BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].material.emissiveTexture.hasAlpha = true;
686
+ BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].material.useAlphaFromEmissiveTexture = true;
687
+ BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].alphaIndex = 1;
688
+ BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1].visibility = 0.9999;
689
+
690
+ window.video = document.getElementById("depth_video").getElementsByTagName("video")[0];
691
+ videoDome.videoTexture.video.oncanplaythrough = function () {
692
+ videoDome.videoTexture.video.play();
693
+ video.play();
694
+ videoDome.videoTexture.video.oncanplaythrough = null;
695
+ video.oncanplaythrough = null;
696
+ };
697
 
698
  window.md = false;
699
  window.r_old = 1.0;
 
706
  window.yold = 0;
707
  window.buffer = null;
708
  window.ctx = null;
 
709
 
710
  document.getElementById("model3D").getElementsByTagName("canvas")[0].addEventListener('pointermove', function(evt) {
711
  if (md === true) {
 
1075
 
1076
  with gr.Column():
1077
  model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl"), ("giant", "vitg")], type="value", value="vits", label='Model Type')
1078
+ processed_video = gr.Video(label="Output Video", format="mp4", elem_id="output_video", interactive=False)
1079
  processed_zip = gr.File(label="Output Archive", interactive=False)
1080
  depth_video = gr.Video(label="Depth Video", format="mp4", elem_id="depth_video", interactive=False, visible=False)
1081
  result = gr.Model3D(label="3D Mesh", clear_color=[0.5, 0.5, 0.5, 0.0], camera_position=[0, 90, 0], zoom_speed=2.0, pan_speed=2.0, interactive=True, elem_id="model3D")