freealise commited on
Commit
6c52b98
1 Parent(s): ad925c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -64
app.py CHANGED
@@ -358,6 +358,66 @@ with gr.Blocks(css=css) as demo:
358
  processed_video = gr.Video(label="Output Video", format="mp4")
359
  processed_zip = gr.File(label="Output Archive")
360
  result = gr.Model3D(label="3D Mesh", clear_color=[0.5, 0.5, 0.5, 0.0], camera_position=[0, 90, 0], interactive=True, elem_id="model3D")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  svg_in = gr.HTML(value="""<svg id='svg_in' height='32' width='256' viewBox='0 0 256 32' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;background-color:#808080;' onpointerdown='
362
  try{
363
  if (document.getElementById(\"pl\").getAttribute(\"points\").length < 256) {
@@ -374,8 +434,8 @@ with gr.Blocks(css=css) as demo:
374
 
375
  this.onpointermove = function(event) {
376
  if (this.title != \"\") {
377
- x = parseInt(event.clientX - event.target.getBoundingClientRect().x);
378
- y = parseInt(event.clientY - event.target.getBoundingClientRect().y);
379
  if (x < 0) { x = 0; } else if (x > 255) { x = 255; }
380
  if (y < 0) { y = 0; } else if (y > 31) { y = 31; }
381
  var pl_a = document.getElementById(\"pl\").getAttribute(\"points\").split(\" \");
@@ -404,8 +464,8 @@ with gr.Blocks(css=css) as demo:
404
  this.title = \"\";
405
  }
406
  this.onpointerdown = function(event) {
407
- xold = parseInt(event.clientX - event.target.getBoundingClientRect().x);
408
- yold = parseInt(event.clientY - event.target.getBoundingClientRect().y);
409
  this.title = xold+\",\"+yold;
410
  }
411
  }
@@ -460,66 +520,6 @@ with gr.Blocks(css=css) as demo:
460
 
461
  document.getElementById(\"model3D\").getElementsByTagName(\"canvas\")[0].style.filter = \"blur(\" + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/2.0*Math.sqrt(2.0) + \"px)\";
462
  '/><span>0.8</span>""")
463
- with gr.Accordion(label="Locations", open=False):
464
- selected = gr.Number(elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
465
- output_frame.select(fn=select_frame, inputs=None, outputs=[output_depth, selected], show_progress='hidden')
466
- output_depth.select(fn=select_frame, inputs=None, outputs=[output_frame, selected], show_progress='hidden')
467
- example_coords = '50.07379596793083,14.437146122950555 50.073799567020004,14.437146774240507 50.07377647505558,14.437161000659017 50.07379496839027,14.437148958238538 50.073823157821664,14.437124189538856'
468
- coords = gr.Textbox(elem_id="coords", value=example_coords, label="Precise coordinates", show_label=False)
469
- offset = gr.HTML(value="""<svg id='offset' height='256' width='256' viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;background-color:transparent;' onpointerdown='
470
- if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
471
- var evt = document.createEvent(\"Event\");
472
- evt.initEvent(\"click\", true, false);
473
- document.getElementById(\"reset_cam\").dispatchEvent(evt);
474
- }
475
- if (this.style.backgroundColor != \"#808080\") {
476
- this.style.backgroundColor = \"#808080\";
477
- this.onpointermove = function(event) {
478
- if (this.title != \"\") {
479
- try{
480
- x = parseInt(event.clientX - event.target.getBoundingClientRect().x);
481
- y = parseInt(event.clientY - event.target.getBoundingClientRect().y);
482
- if (x < 0) { x = 0; } else if (x > 255) { x = 255; }
483
- if (y < 0) { y = 0; } else if (y > 255) { y = 255; }
484
-
485
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x = x-128;
486
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y = y-128;
487
-
488
- xold = x;
489
- yold = y;
490
- document.getElementById(\"cr\").setAttribute(\"cx\", x);
491
- document.getElementById(\"cr\").setAttribute(\"cy\", y);
492
- }catch(e){alert(e);}
493
- }
494
- }
495
- this.onpointerup = function(event) {
496
- this.title = \"\";
497
- }
498
- this.onpointerleave = function(event) {
499
- this.title = \"\";
500
- }
501
- this.onpointerdown = function(event) {
502
- xold = parseInt(event.clientX - event.target.getBoundingClientRect().x);
503
- yold = parseInt(event.clientY - event.target.getBoundingClientRect().y);
504
- this.title = xold+\",\"+yold;
505
- }
506
- this.onclick = function(event) {
507
- alert(BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1]);
508
- try{
509
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y = parseInt(event.clientX - event.target.getBoundingClientRect().x-128)/128*Math.PI;
510
- }catch(e){alert(e);}
511
- }
512
- }
513
- '>
514
- <defs>
515
- <linearGradient id='lg' x1='0%' x2='100%' y1='0%' y2='0%'>
516
- <stop offset='0%' stop-color='white'/>
517
- <stop offset='100%' stop-color='black'/>
518
- </linearGradient>
519
- </defs>
520
- <circle cx="127" cy="127" r="32" id='cr' stroke='none' fill='url(#lg)'/>
521
- </svg>""")
522
-
523
  camera = gr.HTML(value="""<a href='#' id='reset_cam' onclick='
524
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
525
  BABYLON.Engine.LastCreatedScene.activeCamera.metadata = {
 
358
  processed_video = gr.Video(label="Output Video", format="mp4")
359
  processed_zip = gr.File(label="Output Archive")
360
  result = gr.Model3D(label="3D Mesh", clear_color=[0.5, 0.5, 0.5, 0.0], camera_position=[0, 90, 0], interactive=True, elem_id="model3D")
361
+ with gr.Accordion(label="Locations", open=False):
362
+ selected = gr.Number(elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
363
+ output_frame.select(fn=select_frame, inputs=None, outputs=[output_depth, selected], show_progress='hidden')
364
+ output_depth.select(fn=select_frame, inputs=None, outputs=[output_frame, selected], show_progress='hidden')
365
+ example_coords = '50.07379596793083,14.437146122950555 50.073799567020004,14.437146774240507 50.07377647505558,14.437161000659017 50.07379496839027,14.437148958238538 50.073823157821664,14.437124189538856'
366
+ coords = gr.Textbox(elem_id="coords", value=example_coords, label="Precise coordinates", show_label=False)
367
+ offset = gr.HTML(value="""<svg id='offset' height='256' width='256' viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;background-color:transparent;' onpointerdown='
368
+ if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
369
+ var evt = document.createEvent(\"Event\");
370
+ evt.initEvent(\"click\", true, false);
371
+ document.getElementById(\"reset_cam\").dispatchEvent(evt);
372
+ }
373
+ if (this.style.backgroundColor != \"#808080\") {
374
+ this.style.backgroundColor = \"#808080\";
375
+ this.onpointermove = function(event) {
376
+ if (this.title != \"\") {
377
+ try{
378
+ x = parseInt(event.clientX - this.getBoundingClientRect().x);
379
+ y = parseInt(event.clientY - this.getBoundingClientRect().y);
380
+ if (x < 0) { x = 0; } else if (x > 255) { x = 255; }
381
+ if (y < 0) { y = 0; } else if (y > 255) { y = 255; }
382
+
383
+ BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x = x-128;
384
+ BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y = y-128;
385
+
386
+ xold = x;
387
+ yold = y;
388
+ document.getElementById(\"cr\").setAttribute(\"cx\", x);
389
+ document.getElementById(\"cr\").setAttribute(\"cy\", y);
390
+ }catch(e){alert(e);}
391
+ }
392
+ }
393
+ this.onpointerup = function(event) {
394
+ this.title = \"\";
395
+ }
396
+ this.onpointerleave = function(event) {
397
+ this.title = \"\";
398
+ }
399
+ this.onpointerdown = function(event) {
400
+ xold = parseInt(event.clientX - event.target.getBoundingClientRect().x);
401
+ yold = parseInt(event.clientY - event.target.getBoundingClientRect().y);
402
+ this.title = xold+\",\"+yold;
403
+ }
404
+ this.onclick = function(event) {
405
+ alert(BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation);
406
+ try{
407
+ BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y = parseInt(event.clientX - this.getBoundingClientRect().x-128)/128*Math.PI;
408
+ }catch(e){alert(e);}
409
+ }
410
+ }
411
+ '>
412
+ <defs>
413
+ <linearGradient id='lg' x1='0%' x2='100%' y1='0%' y2='0%'>
414
+ <stop offset='0%' stop-color='white'/>
415
+ <stop offset='100%' stop-color='black'/>
416
+ </linearGradient>
417
+ </defs>
418
+ <circle cx="127" cy="127" r="32" id='cr' stroke='none' fill='url(#lg)'/>
419
+ </svg>""")
420
+
421
  svg_in = gr.HTML(value="""<svg id='svg_in' height='32' width='256' viewBox='0 0 256 32' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;background-color:#808080;' onpointerdown='
422
  try{
423
  if (document.getElementById(\"pl\").getAttribute(\"points\").length < 256) {
 
434
 
435
  this.onpointermove = function(event) {
436
  if (this.title != \"\") {
437
+ x = parseInt(event.clientX - this.getBoundingClientRect().x);
438
+ y = parseInt(event.clientY - this.getBoundingClientRect().y);
439
  if (x < 0) { x = 0; } else if (x > 255) { x = 255; }
440
  if (y < 0) { y = 0; } else if (y > 31) { y = 31; }
441
  var pl_a = document.getElementById(\"pl\").getAttribute(\"points\").split(\" \");
 
464
  this.title = \"\";
465
  }
466
  this.onpointerdown = function(event) {
467
+ xold = parseInt(event.clientX - this.getBoundingClientRect().x);
468
+ yold = parseInt(event.clientY - this.getBoundingClientRect().y);
469
  this.title = xold+\",\"+yold;
470
  }
471
  }
 
520
 
521
  document.getElementById(\"model3D\").getElementsByTagName(\"canvas\")[0].style.filter = \"blur(\" + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/2.0*Math.sqrt(2.0) + \"px)\";
522
  '/><span>0.8</span>""")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
  camera = gr.HTML(value="""<a href='#' id='reset_cam' onclick='
524
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
525
  BABYLON.Engine.LastCreatedScene.activeCamera.metadata = {