kwabs22 commited on
Commit
31793a1
·
1 Parent(s): a30137d

Video Overlay far enough -Moving Dot Space next

Browse files
Files changed (2) hide show
  1. bundle.css +1 -0
  2. bundle.js +190 -54
bundle.css CHANGED
@@ -1 +1,2 @@
 
1
  main.svelte-1tky8bj{text-align:center;padding:1em;max-width:240px;margin:0 auto}h1.svelte-1tky8bj{color:#ff3e00;text-transform:uppercase;font-size:4em;font-weight:100}@media(min-width: 640px){main.svelte-1tky8bj{max-width:none}}
 
1
+ #videoContainer.svelte-ufd3fo{border:2px solid red;position:relative;width:720px;height:480px}#videoCanvas.svelte-ufd3fo{border:2px solid black;width:99.5%;height:99.5%;object-fit:cover}#overlayText.svelte-ufd3fo{position:absolute;top:50%;right:50%;color:green;font-style:bold;font-size:15}
2
  main.svelte-1tky8bj{text-align:center;padding:1em;max-width:240px;margin:0 auto}h1.svelte-1tky8bj{color:#ff3e00;text-transform:uppercase;font-size:4em;font-weight:100}@media(min-width: 640px){main.svelte-1tky8bj{max-width:none}}
bundle.js CHANGED
@@ -35,6 +35,12 @@ var app = (function () {
35
  function is_empty(obj) {
36
  return Object.keys(obj).length === 0;
37
  }
 
 
 
 
 
 
38
  function append(target, node) {
39
  target.appendChild(node);
40
  }
@@ -484,27 +490,29 @@ var app = (function () {
484
  }
485
 
486
  /* src\VideoGradioComponentBrainstorming.svelte generated by Svelte v3.59.2 */
 
 
487
  const file$2 = "src\\VideoGradioComponentBrainstorming.svelte";
488
 
489
  function get_each_context$1(ctx, list, i) {
490
  const child_ctx = ctx.slice();
491
- child_ctx[4] = list[i];
492
  return child_ctx;
493
  }
494
 
495
- // (39:4) {#each kitchenOptions as option}
496
  function create_each_block$1(ctx) {
497
  let option;
498
- let t_value = /*option*/ ctx[4] + "";
499
  let t;
500
 
501
  const block = {
502
  c: function create() {
503
  option = element("option");
504
  t = text(t_value);
505
- option.__value = /*option*/ ctx[4];
506
  option.value = option.__value;
507
- add_location(option, file$2, 39, 6, 1076);
508
  },
509
  m: function mount(target, anchor) {
510
  insert_dev(target, option, anchor);
@@ -520,7 +528,7 @@ var app = (function () {
520
  block,
521
  id: create_each_block$1.name,
522
  type: "each",
523
- source: "(39:4) {#each kitchenOptions as option}",
524
  ctx
525
  });
526
 
@@ -530,17 +538,26 @@ var app = (function () {
530
  function create_fragment$2(ctx) {
531
  let h1;
532
  let t1;
 
533
  let video;
534
  let track;
535
  let track_src_value;
536
  let t2;
537
- let div;
538
- let button;
539
  let t4;
 
 
 
 
 
 
 
 
540
  let select;
541
  let mounted;
542
  let dispose;
543
- let each_value = /*kitchenOptions*/ ctx[1];
544
  validate_each_argument(each_value);
545
  let each_blocks = [];
546
 
@@ -551,37 +568,58 @@ var app = (function () {
551
  const block = {
552
  c: function create() {
553
  h1 = element("h1");
554
- h1.textContent = "AI Vision Assistant - Auto prompt HF agent + Cohere + Object detection";
555
  t1 = space();
 
556
  video = element("video");
557
  track = element("track");
558
  t2 = space();
559
- div = element("div");
 
 
 
 
 
 
 
 
560
  button = element("button");
561
  button.textContent = "Verb Test";
562
- t4 = space();
563
  select = element("select");
564
 
565
  for (let i = 0; i < each_blocks.length; i += 1) {
566
  each_blocks[i].c();
567
  }
568
 
569
- add_location(h1, file$2, 26, 0, 606);
570
  attr_dev(track, "kind", "captions");
571
  if (!src_url_equal(track.src, track_src_value = "path/to/your/captions/file.vtt")) attr_dev(track, "src", track_src_value);
572
  attr_dev(track, "srclang", "en");
573
  attr_dev(track, "label", "English");
574
- add_location(track, file$2, 31, 4, 780);
575
  attr_dev(video, "id", "videoCanvas");
576
- attr_dev(video, "width", "1080");
577
- attr_dev(video, "height", "1780");
578
  video.autoplay = true;
579
- add_location(video, file$2, 29, 0, 712);
580
- add_location(button, file$2, 36, 2, 944);
581
- if (/*selectedOption*/ ctx[0] === void 0) add_render_callback(() => /*select_change_handler*/ ctx[2].call(select));
582
- add_location(select, file$2, 37, 2, 994);
583
- attr_dev(div, "id", "frameForButtons");
584
- add_location(div, file$2, 35, 0, 914);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
585
  },
586
  l: function claim(nodes) {
587
  throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
@@ -589,13 +627,24 @@ var app = (function () {
589
  m: function mount(target, anchor) {
590
  insert_dev(target, h1, anchor);
591
  insert_dev(target, t1, anchor);
592
- insert_dev(target, video, anchor);
 
593
  append_dev(video, track);
594
- insert_dev(target, t2, anchor);
595
- insert_dev(target, div, anchor);
596
- append_dev(div, button);
597
- append_dev(div, t4);
598
- append_dev(div, select);
 
 
 
 
 
 
 
 
 
 
599
 
600
  for (let i = 0; i < each_blocks.length; i += 1) {
601
  if (each_blocks[i]) {
@@ -607,16 +656,24 @@ var app = (function () {
607
 
608
  if (!mounted) {
609
  dispose = [
610
- listen_dev(button, "click", testText, false, false, false, false),
611
- listen_dev(select, "change", /*select_change_handler*/ ctx[2])
 
 
612
  ];
613
 
614
  mounted = true;
615
  }
616
  },
617
  p: function update(ctx, [dirty]) {
618
- if (dirty & /*kitchenOptions*/ 2) {
619
- each_value = /*kitchenOptions*/ ctx[1];
 
 
 
 
 
 
620
  validate_each_argument(each_value);
621
  let i;
622
 
@@ -639,7 +696,7 @@ var app = (function () {
639
  each_blocks.length = each_value.length;
640
  }
641
 
642
- if (dirty & /*selectedOption, kitchenOptions*/ 3) {
643
  select_option(select, /*selectedOption*/ ctx[0]);
644
  }
645
  },
@@ -648,9 +705,14 @@ var app = (function () {
648
  d: function destroy(detaching) {
649
  if (detaching) detach_dev(h1);
650
  if (detaching) detach_dev(t1);
651
- if (detaching) detach_dev(video);
652
- if (detaching) detach_dev(t2);
653
- if (detaching) detach_dev(div);
 
 
 
 
 
654
  destroy_each(each_blocks, detaching);
655
  mounted = false;
656
  run_all(dispose);
@@ -668,10 +730,6 @@ var app = (function () {
668
  return block;
669
  }
670
 
671
- function testText() {
672
-
673
- } // Logic for 'verb test' button
674
-
675
  function ocrTest() {
676
 
677
  } // Logic for 'Test OCR' button
@@ -681,39 +739,110 @@ var app = (function () {
681
  validate_slots('VideoGradioComponentBrainstorming', slots, []);
682
  let selectedOption = 'Stove - lu'; // default value
683
  let kitchenOptions = ['Stove - lu', 'Refrigerator - bingxiang', 'Spoon - shao']; /* ... other options ... */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
684
 
685
  // Image source
686
  let imageSrc = 'path_to_your_image/Blooms-Taxonomy-650x366.jpg';
687
 
688
  // Video stream setup
689
  onMount(() => {
690
-
691
- }); // Initialize video stream here
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
692
 
693
  const writable_props = [];
694
 
695
  Object.keys($$props).forEach(key => {
696
- if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(`<VideoGradioComponentBrainstorming> was created with unknown prop '${key}'`);
697
  });
698
 
 
 
 
 
 
 
 
 
 
 
 
 
699
  function select_change_handler() {
700
  selectedOption = select_value(this);
701
  $$invalidate(0, selectedOption);
702
- $$invalidate(1, kitchenOptions);
703
  }
704
 
705
  $$self.$capture_state = () => ({
706
  onMount,
707
  selectedOption,
708
  kitchenOptions,
 
 
 
 
 
 
709
  testText,
710
  ocrTest,
711
- imageSrc
 
 
712
  });
713
 
714
  $$self.$inject_state = $$props => {
715
  if ('selectedOption' in $$props) $$invalidate(0, selectedOption = $$props.selectedOption);
716
- if ('kitchenOptions' in $$props) $$invalidate(1, kitchenOptions = $$props.kitchenOptions);
 
 
 
 
 
 
717
  if ('imageSrc' in $$props) imageSrc = $$props.imageSrc;
718
  };
719
 
@@ -721,7 +850,18 @@ var app = (function () {
721
  $$self.$inject_state($$props.$$inject);
722
  }
723
 
724
- return [selectedOption, kitchenOptions, select_change_handler];
 
 
 
 
 
 
 
 
 
 
 
725
  }
726
 
727
  class VideoGradioComponentBrainstorming extends SvelteComponentDev {
@@ -890,28 +1030,24 @@ var app = (function () {
890
 
891
  // (30:16) {#each comment.items as item}
892
  function create_each_block_1(ctx) {
893
- let div;
894
  let t0_value = /*item*/ ctx[9].title + "";
895
  let t0;
896
  let t1;
897
 
898
  const block = {
899
  c: function create() {
900
- div = element("div");
901
  t0 = text(t0_value);
902
- t1 = space();
903
- add_location(div, file$1, 30, 20, 1088);
904
  },
905
  m: function mount(target, anchor) {
906
- insert_dev(target, div, anchor);
907
- append_dev(div, t0);
908
  insert_dev(target, t1, anchor);
909
  },
910
  p: function update(ctx, dirty) {
911
  if (dirty & /*comments*/ 1 && t0_value !== (t0_value = /*item*/ ctx[9].title + "")) set_data_dev(t0, t0_value);
912
  },
913
  d: function destroy(detaching) {
914
- if (detaching) detach_dev(div);
915
  if (detaching) detach_dev(t1);
916
  }
917
  };
 
35
  function is_empty(obj) {
36
  return Object.keys(obj).length === 0;
37
  }
38
+
39
+ const globals = (typeof window !== 'undefined'
40
+ ? window
41
+ : typeof globalThis !== 'undefined'
42
+ ? globalThis
43
+ : global);
44
  function append(target, node) {
45
  target.appendChild(node);
46
  }
 
490
  }
491
 
492
  /* src\VideoGradioComponentBrainstorming.svelte generated by Svelte v3.59.2 */
493
+
494
+ const { console: console_1 } = globals;
495
  const file$2 = "src\\VideoGradioComponentBrainstorming.svelte";
496
 
497
  function get_each_context$1(ctx, list, i) {
498
  const child_ctx = ctx.slice();
499
+ child_ctx[15] = list[i];
500
  return child_ctx;
501
  }
502
 
503
+ // (85:4) {#each kitchenOptions as option}
504
  function create_each_block$1(ctx) {
505
  let option;
506
+ let t_value = /*option*/ ctx[15] + "";
507
  let t;
508
 
509
  const block = {
510
  c: function create() {
511
  option = element("option");
512
  t = text(t_value);
513
+ option.__value = /*option*/ ctx[15];
514
  option.value = option.__value;
515
+ add_location(option, file$2, 85, 6, 2561);
516
  },
517
  m: function mount(target, anchor) {
518
  insert_dev(target, option, anchor);
 
528
  block,
529
  id: create_each_block$1.name,
530
  type: "each",
531
+ source: "(85:4) {#each kitchenOptions as option}",
532
  ctx
533
  });
534
 
 
538
  function create_fragment$2(ctx) {
539
  let h1;
540
  let t1;
541
+ let div1;
542
  let video;
543
  let track;
544
  let track_src_value;
545
  let t2;
546
+ let div0;
547
+ let t3;
548
  let t4;
549
+ let t5;
550
+ let canvas_1;
551
+ let t6;
552
+ let input;
553
+ let t7;
554
+ let div2;
555
+ let button;
556
+ let t9;
557
  let select;
558
  let mounted;
559
  let dispose;
560
+ let each_value = /*kitchenOptions*/ ctx[4];
561
  validate_each_argument(each_value);
562
  let each_blocks = [];
563
 
 
568
  const block = {
569
  c: function create() {
570
  h1 = element("h1");
571
+ h1.textContent = "AI Vision Assistant - Auto prompt HF agent + Cohere + Object detection - Text write on screen test";
572
  t1 = space();
573
+ div1 = element("div");
574
  video = element("video");
575
  track = element("track");
576
  t2 = space();
577
+ div0 = element("div");
578
+ t3 = text("Text Overlay Test and ");
579
+ t4 = text(/*TestVerb*/ ctx[3]);
580
+ t5 = space();
581
+ canvas_1 = element("canvas");
582
+ t6 = space();
583
+ input = element("input");
584
+ t7 = space();
585
+ div2 = element("div");
586
  button = element("button");
587
  button.textContent = "Verb Test";
588
+ t9 = space();
589
  select = element("select");
590
 
591
  for (let i = 0; i < each_blocks.length; i += 1) {
592
  each_blocks[i].c();
593
  }
594
 
595
+ add_location(h1, file$2, 66, 0, 1800);
596
  attr_dev(track, "kind", "captions");
597
  if (!src_url_equal(track.src, track_src_value = "path/to/your/captions/file.vtt")) attr_dev(track, "src", track_src_value);
598
  attr_dev(track, "srclang", "en");
599
  attr_dev(track, "label", "English");
600
+ add_location(track, file$2, 72, 4, 2006);
601
  attr_dev(video, "id", "videoCanvas");
 
 
602
  video.autoplay = true;
603
+ attr_dev(video, "class", "svelte-ufd3fo");
604
+ add_location(video, file$2, 70, 2, 1965);
605
+ attr_dev(div0, "id", "overlayText");
606
+ attr_dev(div0, "class", "svelte-ufd3fo");
607
+ add_location(div0, file$2, 74, 2, 2111);
608
+ attr_dev(div1, "id", "videoContainer");
609
+ attr_dev(div1, "class", "svelte-ufd3fo");
610
+ add_location(div1, file$2, 68, 0, 1911);
611
+ attr_dev(canvas_1, "id", "myCanvas");
612
+ set_style(canvas_1, "border", "2px solid black");
613
+ attr_dev(canvas_1, "width", "500");
614
+ attr_dev(canvas_1, "height", "500");
615
+ add_location(canvas_1, file$2, 77, 0, 2186);
616
+ attr_dev(input, "type", "text");
617
+ add_location(input, file$2, 78, 0, 2294);
618
+ add_location(button, file$2, 82, 2, 2429);
619
+ if (/*selectedOption*/ ctx[0] === void 0) add_render_callback(() => /*select_change_handler*/ ctx[9].call(select));
620
+ add_location(select, file$2, 83, 2, 2479);
621
+ attr_dev(div2, "id", "frameForButtons");
622
+ add_location(div2, file$2, 81, 0, 2399);
623
  },
624
  l: function claim(nodes) {
625
  throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
 
627
  m: function mount(target, anchor) {
628
  insert_dev(target, h1, anchor);
629
  insert_dev(target, t1, anchor);
630
+ insert_dev(target, div1, anchor);
631
+ append_dev(div1, video);
632
  append_dev(video, track);
633
+ append_dev(div1, t2);
634
+ append_dev(div1, div0);
635
+ append_dev(div0, t3);
636
+ append_dev(div0, t4);
637
+ insert_dev(target, t5, anchor);
638
+ insert_dev(target, canvas_1, anchor);
639
+ /*canvas_1_binding*/ ctx[7](canvas_1);
640
+ insert_dev(target, t6, anchor);
641
+ insert_dev(target, input, anchor);
642
+ set_input_value(input, /*textToDisplay*/ ctx[2]);
643
+ insert_dev(target, t7, anchor);
644
+ insert_dev(target, div2, anchor);
645
+ append_dev(div2, button);
646
+ append_dev(div2, t9);
647
+ append_dev(div2, select);
648
 
649
  for (let i = 0; i < each_blocks.length; i += 1) {
650
  if (each_blocks[i]) {
 
656
 
657
  if (!mounted) {
658
  dispose = [
659
+ listen_dev(input, "input", /*input_input_handler*/ ctx[8]),
660
+ listen_dev(input, "input", /*updateText*/ ctx[6], false, false, false, false),
661
+ listen_dev(button, "click", /*testText*/ ctx[5], false, false, false, false),
662
+ listen_dev(select, "change", /*select_change_handler*/ ctx[9])
663
  ];
664
 
665
  mounted = true;
666
  }
667
  },
668
  p: function update(ctx, [dirty]) {
669
+ if (dirty & /*TestVerb*/ 8) set_data_dev(t4, /*TestVerb*/ ctx[3]);
670
+
671
+ if (dirty & /*textToDisplay*/ 4 && input.value !== /*textToDisplay*/ ctx[2]) {
672
+ set_input_value(input, /*textToDisplay*/ ctx[2]);
673
+ }
674
+
675
+ if (dirty & /*kitchenOptions*/ 16) {
676
+ each_value = /*kitchenOptions*/ ctx[4];
677
  validate_each_argument(each_value);
678
  let i;
679
 
 
696
  each_blocks.length = each_value.length;
697
  }
698
 
699
+ if (dirty & /*selectedOption, kitchenOptions*/ 17) {
700
  select_option(select, /*selectedOption*/ ctx[0]);
701
  }
702
  },
 
705
  d: function destroy(detaching) {
706
  if (detaching) detach_dev(h1);
707
  if (detaching) detach_dev(t1);
708
+ if (detaching) detach_dev(div1);
709
+ if (detaching) detach_dev(t5);
710
+ if (detaching) detach_dev(canvas_1);
711
+ /*canvas_1_binding*/ ctx[7](null);
712
+ if (detaching) detach_dev(t6);
713
+ if (detaching) detach_dev(input);
714
+ if (detaching) detach_dev(t7);
715
+ if (detaching) detach_dev(div2);
716
  destroy_each(each_blocks, detaching);
717
  mounted = false;
718
  run_all(dispose);
 
730
  return block;
731
  }
732
 
 
 
 
 
733
  function ocrTest() {
734
 
735
  } // Logic for 'Test OCR' button
 
739
  validate_slots('VideoGradioComponentBrainstorming', slots, []);
740
  let selectedOption = 'Stove - lu'; // default value
741
  let kitchenOptions = ['Stove - lu', 'Refrigerator - bingxiang', 'Spoon - shao']; /* ... other options ... */
742
+ let canvas;
743
+ let ctx;
744
+ let textToDisplay = 'Initial Text';
745
+ let counter = 0;
746
+ let hud_text;
747
+ let TestVerb = "|Test verb|";
748
+
749
+ // Functions for button commands
750
+ function testText() {
751
+ // Logic for 'verb test' button
752
+ const randomIndex = Math.floor(Math.random() * kitchenOptions.length);
753
+
754
+ $$invalidate(3, TestVerb = kitchenOptions[randomIndex]);
755
+ }
756
 
757
  // Image source
758
  let imageSrc = 'path_to_your_image/Blooms-Taxonomy-650x366.jpg';
759
 
760
  // Video stream setup
761
  onMount(() => {
762
+ // Initialize video stream here
763
+ ctx = canvas.getContext('2d');
764
+
765
+ setInterval(
766
+ () => {
767
+ drawText(textToDisplay);
768
+ },
769
+ 1000
770
+ ); // Update every second
771
+ });
772
+
773
+ function drawText(hud_info) {
774
+ if (ctx) {
775
+ hud_text = "HUD Info Update: " + counter++ + " " + hud_info;
776
+ ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear the canvas
777
+ ctx.font = '30px Arial';
778
+ ctx.fillStyle = 'black';
779
+ ctx.fillText(hud_text, 50, 50);
780
+ }
781
+ }
782
+
783
+ function updateText(event) {
784
+ $$invalidate(2, textToDisplay = event.target.value);
785
+ drawText();
786
+ }
787
+
788
+ // Camera as Video Stream
789
+ navigator.mediaDevices.getUserMedia({ video: true }).then(stream => {
790
+ const video = document.getElementById('videoCanvas');
791
+ video.srcObject = stream;
792
+ }).catch(err => {
793
+ console.error("Error accessing the camera: ", err);
794
+ });
795
 
796
  const writable_props = [];
797
 
798
  Object.keys($$props).forEach(key => {
799
+ if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console_1.warn(`<VideoGradioComponentBrainstorming> was created with unknown prop '${key}'`);
800
  });
801
 
802
+ function canvas_1_binding($$value) {
803
+ binding_callbacks[$$value ? 'unshift' : 'push'](() => {
804
+ canvas = $$value;
805
+ $$invalidate(1, canvas);
806
+ });
807
+ }
808
+
809
+ function input_input_handler() {
810
+ textToDisplay = this.value;
811
+ $$invalidate(2, textToDisplay);
812
+ }
813
+
814
  function select_change_handler() {
815
  selectedOption = select_value(this);
816
  $$invalidate(0, selectedOption);
817
+ $$invalidate(4, kitchenOptions);
818
  }
819
 
820
  $$self.$capture_state = () => ({
821
  onMount,
822
  selectedOption,
823
  kitchenOptions,
824
+ canvas,
825
+ ctx,
826
+ textToDisplay,
827
+ counter,
828
+ hud_text,
829
+ TestVerb,
830
  testText,
831
  ocrTest,
832
+ imageSrc,
833
+ drawText,
834
+ updateText
835
  });
836
 
837
  $$self.$inject_state = $$props => {
838
  if ('selectedOption' in $$props) $$invalidate(0, selectedOption = $$props.selectedOption);
839
+ if ('kitchenOptions' in $$props) $$invalidate(4, kitchenOptions = $$props.kitchenOptions);
840
+ if ('canvas' in $$props) $$invalidate(1, canvas = $$props.canvas);
841
+ if ('ctx' in $$props) ctx = $$props.ctx;
842
+ if ('textToDisplay' in $$props) $$invalidate(2, textToDisplay = $$props.textToDisplay);
843
+ if ('counter' in $$props) counter = $$props.counter;
844
+ if ('hud_text' in $$props) hud_text = $$props.hud_text;
845
+ if ('TestVerb' in $$props) $$invalidate(3, TestVerb = $$props.TestVerb);
846
  if ('imageSrc' in $$props) imageSrc = $$props.imageSrc;
847
  };
848
 
 
850
  $$self.$inject_state($$props.$$inject);
851
  }
852
 
853
+ return [
854
+ selectedOption,
855
+ canvas,
856
+ textToDisplay,
857
+ TestVerb,
858
+ kitchenOptions,
859
+ testText,
860
+ updateText,
861
+ canvas_1_binding,
862
+ input_input_handler,
863
+ select_change_handler
864
+ ];
865
  }
866
 
867
  class VideoGradioComponentBrainstorming extends SvelteComponentDev {
 
1030
 
1031
  // (30:16) {#each comment.items as item}
1032
  function create_each_block_1(ctx) {
 
1033
  let t0_value = /*item*/ ctx[9].title + "";
1034
  let t0;
1035
  let t1;
1036
 
1037
  const block = {
1038
  c: function create() {
 
1039
  t0 = text(t0_value);
1040
+ t1 = text(" | \r\n ");
 
1041
  },
1042
  m: function mount(target, anchor) {
1043
+ insert_dev(target, t0, anchor);
 
1044
  insert_dev(target, t1, anchor);
1045
  },
1046
  p: function update(ctx, dirty) {
1047
  if (dirty & /*comments*/ 1 && t0_value !== (t0_value = /*item*/ ctx[9].title + "")) set_data_dev(t0, t0_value);
1048
  },
1049
  d: function destroy(detaching) {
1050
+ if (detaching) detach_dev(t0);
1051
  if (detaching) detach_dev(t1);
1052
  }
1053
  };