-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathvia.html
5109 lines (4475 loc) · 173 KB
/
via.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--
VGG Image Annotator (via)
www.robots.ox.ac.uk/~vgg/software/via/
Copyright (c) 2016, Abhishek Dutta, Visual Geometry Group, Oxford University.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-->
<title>VGG Image Annotator</title>
<meta name="author" content="Abhishek Dutta">
<meta name="description" content="VIA is a standalone image annotator application packaged as a single HTML file (< 200 KB) that runs on most modern web browsers.">
<!--
Development of VIA is supported by the EPSRC programme grant
Seebibyte: Visual Search for the Era of Big Data (EP/M013774/1).
Using Google Analytics, we record the usage of this application.
This data is used in reporting of this programme grant.
-->
<script type="text/javascript">
//<!--AUTO_INSERT_GOOGLE_ANALYTICS_JS_HERE-->
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-20555581-2', 'auto');
ga('set', 'page', '/via-1.0.0.html');
ga('send', 'pageview');
</script>
<!-- CSS style definition -->
<style type="text/css">
body {
min-width: 800px;
padding: 0;
margin: 0;
font-family: sans-serif;
}
/* Top panel : #navbar, #toolbar */
.top_panel {
position: fixed;
top: 0;
left: 0;
display: block;
font-size: medium;
background-color: #000000;
color: white;
z-index: 10;
margin: 0;
padding: 0;
width: 100%;
}
.navbar {
display: inline-block;
}
.navbar ul {
display: inline;
list-style-type: none;
overflow: hidden;_via_img_metadata
}
.navbar li {
float: left;
}
.navbar li a, .drop_menu_item {
display: inline-block;
color: white;
padding: 0.65em 1.2em;
text-decoration: none;
}
.navbar li a:hover, .dropdown:hover {
background-color: #999999;
cursor: pointer;
}
.navbar li.dropdown {
display: inline-block;
}
.navbar .dropdown-content {
display: none;
position: absolute;
background-color: #333333;
min-width: 120px;
border: 1px solid #ffffff;
font-size: small;
}
.navbar .dropdown-content a {
color: #ffffff;
padding: 0.4em 0.6em;
text-decoration: none;
display: block;
text-align: left;
background-color: #333333;
float: none;
}
.navbar .dropdown-content a:hover {
background-color: #000000;
color: #ffff00;
}
.navbar .dropdown:hover .dropdown-content {
display: block;
}
.toolbar {
display: inline-block;
color: white;
vertical-align: top;
}
.toolbar ul {
display: inline;
list-style-type: none;
overflow: hidden;
}
.toolbar li {
font-size: medium;
float: left;
padding: 0.65em 0.3em;
color: white;
}
.toolbar li:hover {
background-color: #333333;
color: red;
cursor: pointer;
}
#fileinfo {
font-size: small;
padding: 1.2em 0.8em;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* Middle panel: containing #image_panel, #leftsidebar */
.middle_panel {
position: relative;
display: table;
table-layout: fixed;
width: 100%;
z-index: 1;
padding: 0;
top: 3.5em;
/*padding-top: 1.0125em; ensures the mouse event (x,y) coordinates are integer */
}
#leftsidebar {
display: table-cell;
width: 250px;
z-index: 10;
vertical-align: top;
}
#display_area {
display: table-cell;
width: 100%;
z-index: 1;
margin: 0;
padding-left: 1em;
vertical-align: top;
}
#canvas_panel {
position: relative;
margin: 0;
padding: 0;
}
#canvas_panel canvas:focus {
outline: none;
}
#leftsidebar_collapse_panel {
display: table-cell;
position: relative;
width: 10px;
z-index: 1;
vertical-align: top;
font-size: small;
}
#leftsidebar_collapse_button {
background-color: black;
width: 10px;
height: 25px;
color: white;
padding: 0.2em;
border-radius: 0px 5px 5px 0px;
font-size: large;
}
#leftsidebar_collapse_button:hover {
color: red;
cursor: pointer;
}
/* Left sidebar accordion */
button.leftsidebar_accordion {
font-size: large;
background-color: #f2f2f2;
cursor: pointer;
padding: 0.5em 0.5em;
width: 100%;
text-align: left;
border: 0;
outline: none;
}
button.leftsidebar_accordion:focus {
outline: none;
}
button.leftsidebar_accordion.active, button.leftsidebar_accordion:hover {
background-color: #e6e6e6;
}
button.leftsidebar_accordion:after {
content: '\02795';
color: #4d4d4d;
float: right;
}
button.leftsidebar_accordion.active:after {
content: '\2796';
}
.leftsidebar_accordion_panel {
display: none;
padding-top: 0;
padding-left: 0.5em;
font-size: small;
border-right: 2px solid #f2f2f2;
border-bottom: 2px solid #f2f2f2;
}
.leftsidebar_accordion_panel.show {
display: block;
}
/* Region shape selection panel inside leftsidebar */
ul.region_shape {
font-size: xx-large;
list-style-type: none;
overflow: hidden;
padding: 0.4em 0;
margin: 0;
}
ul.region_shape li{
float: left;
padding: 0 0.2em;
fill: #ffffff;
stroke: #000000;
}
ul.region_shape li:hover {
cursor: pointer;
fill: #ffffff;
stroke: #ff0000;
}
ul.region_shape .selected {
fill: #ffffff;
stroke: #ff0000;
}
/* Loaded image list shown in leftsidebar panel */
#img_fn_list {
font-size: small;
overflow: scroll;
min-height: 10rem;
max-height: 30rem;
}pack_via
#img_fn_list_panel input {
width: 88%;
border: 1px solid #ccc;
margin: 0.6rem 0;
padding: 0.2rem 0.4rem;
}
#img_fn_list ul {
position: relative;
line-height: 1.3em;
margin: 0;
padding: 0;
list-style-type: none;
}
#img_fn_list li {
white-space: nowrap;
}
#img_fn_list li:hover {
background-color: #cccccc;
color: #000000;
cursor: pointer;
}
#message_panel {
position: fixed;
left: 0;
bottom: 0px;
line-height: 3em;
width: 100%;
background-color: #000000;
color: #ffff00;
font-size: small;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
z-index: 1000;
}
#invisible_file_input {
width: 0.1px;
height: 0.1px;
opacity: 0;
overflow: hidden;
position: absolute;
z-index: -1;
}
.text_panel {
display: none;
margin: auto;
font-size: medium;
line-height: 1.3em;
margin: 0;
max-width: 700px;
}
.text_panel li {
margin: 1em 0;
text-align: left;
}
.text_panel p {
text-align: left;
}
.action_text_link {
background-color: #aaeeff;
color: #000000;
}
.action_text_link:hover {
cursor: pointer;
}
.svg_button:hover {
cursor: pointer;
}
.tool_button {
color: blue;
cursor: pointer;
}
.tool_button:hover {
color: red;
}
/* region and file attributes input panel (spreadsheet like) */
#attributes_panel {
display: none;_via_img_metadata
position: fixed;
bottom: 0;
z-index: 10;
width: 100%;
max-height: 30%;
overflow: auto;
background-color: #ffffff;
border-top: 4px solid #000000;
padding: 0em 0em;
padding-bottom: 2em;
font-size: small;
}
#attributes_panel table {
border-collapse: collapse;
table-layout: fixed;
margin: 1em;
margin-bottom: 2em;
}
#attributes_panel td {
border: 1px solid #999999;
padding: 1em 1em;
margin: 0;
height: 1em;
white-space: nowrap;
vertical-align: top;
}
#attributes_panel tr:first-child td, #attributes_panel td:first-child {
padding: 1em 1em;
text-align: center;
}
#attributes_panel input {
border: none;
padding: 0;
margin: 0;
display: table-cell;
height: 1.3em;
font-size: small;
background-color: #ffffff;
vertical-align: top;
}
#attributes_panel input:hover {
background-color: #e6e6e6;
}
#attributes_panel input:focus {
background-color: #e6e6e6;
}
#attributes_panel input:not(:focus) {
text-align: center;
}
#attributes_panel textarea {
border: none;
padding: 0;
margin: 0;
display: table-cell;
font-size: small;
background-color: #ffffff;
}
#attributes_panel textarea:hover {
background-color: #e6e6e6;
}
#attributes_panel textarea:focus {
background-color: #e6e6e6;
}
#attributes_panel_toolbar {
display: block;
height: 30px;
width: 100%;
position: relative;
padding: 0;
margin: 0;
}
.attributes_panel_button {
width: 10px;
color: black;
font-size: x-large;
margin-left: 0.5em;
padding: 0;
}
.attributes_panel_button:hover {
color: red;
cursor: pointer;
}
/* layers of canvas */
#image_panel {
position: relative;
display: inline-block;
margin: auto;
margin-top: 1em;
}
#image_canvas {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
}
#region_canvas {
position: absolute;
top: 0px;
left: 0px;
z-index: 2;
}
/* Loading spinbar */
.loading_spinbox {
display: inline-block;
border: 0.4em solid #cccccc;
border-radius: 50%;
border-top: 0.4em solid #000000;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body onload="_via_init()" onresize="_via_update_ui_components()">
<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="shape_rectangle">
<title>Rectangular region shape</title>
<rect width="20" height="12" x="6" y="10" stroke-width="2"/>
</symbol>
<symbol id="shape_circle">
<title>Circular region shape</title>
<circle r="10" cx="16" cy="16" stroke-width="2"/>
</symbol>
<symbol id="shape_ellipse">
<title>Elliptical region shape</title>
<ellipse rx="12" ry="8" cx="16" cy="16" stroke-width="2"/>
</symbol>
<symbol id="shape_polygon">
<title>Polygon region shape</title>
<path d="M 15.25,2.2372 3.625,11.6122 6,29.9872 l 20.75,-9.625 2.375,-14.75 z" stroke-width="2"/>
</symbol>
<symbol id="shape_point">
<title>Point region shape</title>
<circle r="3" cx="16" cy="16" stroke-width="2"/>
</symbol>
<symbol id="shape_polyline">
<title>Polyline region shape</title>
<!--<path d="M 15.25,2.2372 3.625,11.6122 6,29.9872 l 20.75,-9.625" stroke-width="2"/>-->
<path d="M 2,12 10,24 18,12 24,18" stroke-width="2"/>
<circle r="1" cx="2" cy="12" stroke-width="2"/>
<circle r="1" cx="10" cy="24" stroke-width="2"/>
<circle r="1" cx="18" cy="12" stroke-width="2"/>
<circle r="1" cx="24" cy="18" stroke-width="2"/>
</symbol>
</defs>
</svg>
<div class="top_panel" id="ui_top_panel">
<!-- Navigation menu -->
<div class="navbar">
<ul>
<li><a onclick="show_home_panel()" title="Home">Home</a></li>
<li class="dropdown"><a title="Image" class="drop_menu_item">Image ▾</a>
<div class="dropdown-content">
<a onclick="sel_local_images()" title="Load (or add) a set of images from local disk">Load or Add Images</a>
<a onclick="toggle_img_fn_list_visibility()" title="Browse currently loaded images">List Images</a>
</div>
</li>
<li class="dropdown"><a title="Annotations" class="drop_menu_item">Annotation ▾</a>
<div class="dropdown-content">
<a onclick="show_annotation_data()" title="View annotations">View annotations</a>
<a onclick="download_all_region_data('csv')" title="Save image region annotations as a CSV(comma separated value) file">Save as VIA-CSV</a>
<a onclick="download_all_region_data('json')" title="Save image region annotations as a JSON(Javascript Object Notation) file">Save as VIA-JSON</a>
<a onclick="download_all_region_data('coco')" title="Save image region annotations as a JSON(Javascript Object Notation) file">Save as COCO-JSON</a>
<a onclick="sel_local_data_file('coco_infer')" title="Import existing region data from CSV or JSON file">Import COCO Results</a>
<a onclick="sel_local_data_file('coco_ann')" title="Import existing region data from CSV or JSON file">Import COCO Instances</a>
<a onclick="sel_local_data_file('coco_poly')" title="Import existing region data from CSV or JSON file">Import COCO as Polygons</a>
<a onclick="sel_local_data_file('annotations')" title="Import existing region data from CSV or JSON file">Import VIA</a>
</div>
</li>
<li class="dropdown"><a title="View" class="drop_menu_item">View ▾</a>
<div class="dropdown-content">
<a onclick="toggle_leftsidebar()" title="Show/hide left sidebar">Show/hide left sidebar</a>
<a onclick="toggle_region_boundary_visibility()" title="Show or hide region boundaries">Show/hide region boundaries</a>
<a onclick="toggle_region_id_visibility()" title="Show or hide region labels">Show/hide region labels</a>
</div>
</li>
<li class="dropdown"><a onclick="show_about_panel()" title="Help">Help ▾</a>
<div class="dropdown-content">
<a onclick="show_getting_started_panel()" title="Getting started with VGG Image Annotator (VIA)">Getting Started</a>
<a onclick="show_license_panel()" title="VIA License">License</a>
<a onclick="show_about_panel()" title="About VGG Image Annotator (VIA)">About</a>
</div>
</li>
</ul>
</div> <!-- end of #navbar -->
<!-- Shortcut toolbar -->
<div class="toolbar">
<ul>
<!--
<li onclick="sel_local_images()" title="Load or Add Images">⋯</li>
<li onclick="sel_local_data_file('annotations')" title="Import Annotations">↑</li>
<li onclick="download_all_region_data('csv')" title="Save Annotations (as CSV)">⤓</li>
-->
<li id="toolbar_prev_img" style="margin-left: 1em;" onclick="move_to_prev_image()" title="Previous Image">←</li>
<li id="toolbar_next_img" onclick="move_to_next_image()" title="Next Image">→</li>
<li id="toolbar_list_img" onclick="toggle_img_list()" title="List Images">☰</li>
<li id="toolbar_zoom_out" style="margin-left: 2em;" onclick="zoom_out()" title="Zoom Out">−</li>
<li id="toolbar_zoom_in" onclick="zoom_in()" title="Zoom In">+</li>
<li id="toolbar_zoom_reset" onclick="reset_zoom_level()" title="Zoom Reset">=</li>
<li id="toolbar_copy_region" style="margin-left: 2em;" onclick="copy_sel_regions()" title="Copy Region">c</li>
<li id="toolbar_paste_region" onclick="paste_sel_regions()" title="Paste Region">v</li>
<li id="toolbar_sel_all_region" onclick="sel_all_regions()" title="Select All Regions">a</li>
<li id="toolbar_del_region" onclick="del_sel_regions()" title="Delete Region">×</li>
</ul>
</div> <!-- endof #toolbar -->
<input type="file" id="invisible_file_input" multiple name="files[]" style="display:none">
</div> <!-- endof #top_panel -->
<!-- Middle Panel contains a left-sidebar and image display areas -->
<div class="middle_panel">
<div id="leftsidebar">
<button class="leftsidebar_accordion active">Region Shape</button>
<div class="leftsidebar_accordion_panel show">
<ul class="region_shape">
<li id="region_shape_rect" class="selected" onclick="select_region_shape('rect')" title="Rectangle"><svg height="32" viewbox="0 0 32 32"><use xlink:href="#shape_rectangle"></use></svg></li>
<li id="region_shape_circle" onclick="select_region_shape('circle')" title="Circle"><svg height="32" viewbox="0 0 32 32"><use xlink:href="#shape_circle"></use></svg></li>
<li id="region_shape_ellipse" onclick="select_region_shape('ellipse')" title="Ellipse"><svg height="32" viewbox="0 0 32 32"><use xlink:href="#shape_ellipse"></use></svg></li>
<li id="region_shape_polygon" onclick="select_region_shape('polygon')" title="Polygon"><svg height="32" viewbox="0 0 32 32"><use xlink:href="#shape_polygon"></use></svg></li>
<li id="region_shape_point" onclick="select_region_shape('point')" title="Point"><svg height="32" viewbox="0 0 32 32"><use xlink:href="#shape_point"></use></svg></li>
<li id="region_shape_polyline" onclick="select_region_shape('polyline')" title="Polyline"><svg height="32" viewbox="0 0 32 32"><use xlink:href="#shape_polyline"></use></svg></li>
</ul>
</div>
<button class="leftsidebar_accordion active" id="loaded_img_panel_title">Loaded Images</button>
<div class="leftsidebar_accordion_panel show" id="img_fn_list_panel">
<div>
<input type="text" placeholder="Filter using regular expression" oninput="img_fn_list_onregex()" id="img_fn_list_regex">
</div>
<div id="img_fn_list"></div>
</div>
<button onclick="toggle_reg_attr_panel()" class="leftsidebar_accordion" id="reg_attr_panel_button">Region Attributes</button>
<button onclick="toggle_file_attr_panel()" class="leftsidebar_accordion" id="file_attr_panel_button">File Attributes</button>
<button class="leftsidebar_accordion">Keyboard Shortcuts</button>
<div class="leftsidebar_accordion_panel">
<table style="padding: 2em 0em;">
<tr>
<td style="width: 6em;">n/p (←/→)</td>
<td>Next/Previous image</td>
</tr>
<tr>
<td>+ / - / =</td>
<td>Zoom in/out/reset</td>
</tr>
<tr>
<td>Ctrl + c</td>
<td>Copy sel. regions</td>
</tr>
<tr>
<td>Ctrl + v</td>
<td>Paste sel. regions</td>
</tr>
<tr>
<td>Ctrl + a</td>
<td>Select all regions</td>
</tr>
<tr>
<td>Del, Bkspc</td>
<td>Delete image region</td>
</tr>
<tr>
<td>Esc</td>
<td>Cancel operation</td>
</tr>
<tr>
<td>Ctrl + s</td>
<td>Download annotations</td>
</tr>
<tr>
<td>Spacebar</td>
<td>Toggle image list</td>
</tr>
</table>
</div>
</div> <!-- end of leftsidebar -->
<div id="leftsidebar_collapse_panel">
<div onclick="toggle_leftsidebar()" id="leftsidebar_collapse_button" title="Show/hide left toolbar">
◂</div>
</div>
<!-- Main display area: contains image canvas, ... -->
<div id="display_area">
<div id="canvas_panel">
<canvas id="image_canvas"></canvas>
<canvas id="region_canvas" tabindex="1">Sorry, your browser does not support HTML5 Canvas functionality which is required for this application.</canvas>
</div>
<div>
<div class="text_panel" id="via_start_info_panel">Starting VGG Image Annotator ...</div>
<div class="text_panel" style="padding: 1em; border: 1px solid #cccccc;" id="about_panel">
<p style="font-size: 2em;">VGG Image Annotator</p>
<p style="font-size: 0.8em;">version <a href="https://gitlab.com/vgg/via/blob/via-1.x.y/CHANGELOG">1.0.6</a></p>
<p>
VGG Image Annotator (VIA) is an <a href="https://gitlab.com/vgg/via/">open source project</a>
developed at the <a href="http://www.robots.ox.ac.uk/~vgg/">Visual Geometry Group</a>
and released under the BSD-2 clause <a href="https://gitlab.com/vgg/via/blob/master/LICENSE">license</a>.
With this standalone application, you can define regions in an image and create a textual description of those regions.
Such image regions and descriptions are useful for supervised training of learning algorithms.
</p>
<p>Features:</p>
<ul>
<li>based solely on HTML, CSS and Javascript (no external javascript libraries)</li>
<li>can be used off-line (full application in a single html file of size < 200KB)</li>
<li>requires nothing more than a modern web browser</li>
<li>supported region shapes: rectangle, circle, ellipse, polygon and point</li>
<li>import/export of region data in csv and json file format</li>
</ul>
<p>For more details, visit <a href="http://www.robots.ox.ac.uk/~vgg/software/via/">http://www.robots.ox.ac.uk/~vgg/software/via/</a>.</p>
<p> </p>
<p>Copyright © 2016-2018, <a href="mailto:[email protected]">Abhishek Dutta</a> (Visual Geometry Group, Oxford University)</p>
</div>
<div class="text_panel" id="getting_started_panel">
<h1>Getting Started</h1>
<ol>
<li>Click [Image > Load or Add Images] in the top menu bar to load a set of images that you wish to annotate.</li>
<li>Press n (or p) to navigate through the loaded images. You can also use the ← and → icons in the top panel toolbar for navigation.</li>
<li>Click <b>Region Attributes</b> in the left panel to reveal a panel in the bottom. Click <b>[Add New]</b> tp add a new attribute. For example:
<pre>
object_name
object_color
</pre>
You can add more region attributes according to you needs.
<li>In the <b>Region Shape</b> section in the left panel, click the rectangular shape</li>
<li>On the image area, keep pressing the right click button as you drag the mouse cursor. This will draw a rectangular region on the image.</li>
<li>This newly created region is automatically selected. Now you can enter the attribute value for this region in the bottom panel. For example:
<pre>
object_name = dog
object_color = white
</pre>
You can annotate multiple regions in this image or other images and assign a value to each pre-defined attribute.</li>
<li>To download the annotated region data, click <b>[Annotation > Save as CSV]</b> in the top menu bar. This will download a text file containing region shape and attribute data.</li>
<li>Next time, you can start from the point your left by first loading the images and then importing the CSV file (downloaded in step 7) by clicking <b>[Annotation > Import]</b>.
</li></ol>
</div>
<div class="text_panel" id="license_panel">
<pre>
Copyright (c) 2016-2018, Abhishek Dutta, Visual Geometry Group, Oxford University.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
</pre>
</div>
</div>
</div>
</div>
<!-- region and file attributes input panel -->
<div id="attributes_panel">
<div id="attributes_panel_toolbar">
<div onclick="toggle_attributes_input_panel()" class="attributes_panel_button">×</div>
</div>
<table id="attributes_panel_table"></table>
</div>
<!-- to show status messages -->
<div id="message_panel"></div>
<!-- this vertical spacer is needed to allow scrollbar to show
items like Keyboard Shortcut hidden under the attributes panel -->
<div style="width: 100%;" id="vertical_space"></div>
<script type="text/javascript">
//<!--AUTO_INSERT_VIA_DEMO_JS_HERE-->
</script>
<script type="text/javascript">
//<!--AUTO_INSERT_VIA_JS_HERE-->
/*
VGG Image Annotator (via)
www.robots.ox.ac.uk/~vgg/software/via/
Copyright (c) 2016-2018, Abhishek Dutta, Visual Geometry Group, Oxford University.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
See Contributors.md file for a list of developers who have contributed code
to VIA codebase.
/*
This source code is organized in the following groups:
- Data structure for annotations
- Initialization routine
- Handlers for top navigation bar
- Local file uploaders
- Data Importer
- Data Exporter
- Maintainers of user interface
- Image click handlers
- Canvas update routines
- Region collision routines
- Shortcut key handlers
- Persistence of annotation data in browser cache (i.e. localStorage)
- Handlers for attributes input panel (spreadsheet like user input panel)
See [Source code documentation](https://gitlab.com/vgg/via/blob/develop/CodeDoc.md)
and [Contributing Guidelines](https://gitlab.com/vgg/via/blob/develop/CONTRIBUTING.md)
for more details.
*/
"use strict";
var VIA_VERSION = '1.0.6';
var VIA_NAME = 'VGG Image Annotator';
var VIA_SHORT_NAME = 'VIA';
var VIA_REGION_SHAPE = { RECT:'rect',
CIRCLE:'circle',
ELLIPSE:'ellipse',
POLYGON:'polygon',
POINT:'point',
POLYLINE:'polyline'
};
var VIA_REGION_EDGE_TOL = 20; // pixel
var VIA_REGION_CONTROL_POINT_SIZE = 2;
var VIA_REGION_POINT_RADIUS = 3;
var VIA_POLYGON_VERTEX_MATCH_TOL = 5;
var VIA_REGION_MIN_DIM = 3;
var VIA_MOUSE_CLICK_TOL = 2;
var VIA_ELLIPSE_EDGE_TOL = 0.2; // euclidean distance
var VIA_THETA_TOL = Math.PI/18; // 10 degrees
var VIA_POLYGON_RESIZE_VERTEX_OFFSET = 100;
var VIA_CANVAS_DEFAULT_ZOOM_LEVEL_INDEX = 3;
var VIA_CANVAS_ZOOM_LEVELS = [0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, 4, 5];
var VIA_THEME_REGION_BOUNDARY_WIDTH = 4;
var VIA_THEME_BOUNDARY_LINE_COLOR = "#1a1a1a";
var VIA_THEME_BOUNDARY_FILL_COLOR = "#aaeeff";
var VIA_INFER_BOUNDARY_FILL_COLOR = "#00ff00";
var VIA_ANNO_BOUNDARY_FILL_COLOR = "#ffcc00";
var VIA_THEME_SEL_REGION_FILL_COLOR = "#808080";
var VIA_THEME_SEL_REGION_FILL_BOUNDARY_COLOR = "#000000";
var VIA_THEME_SEL_REGION_OPACITY = 0.5;
var VIA_THEME_MESSAGE_TIMEOUT_MS = 6000;
var VIA_THEME_ATTRIBUTE_VALUE_FONT = '10pt Sans';
var VIA_THEME_CONTROL_POINT_COLOR = '#ff0000';
var VIA_CSV_SEP = ',';
var VIA_CSV_QUOTE_CHAR = '"';
var VIA_CSV_KEYVAL_SEP = ':';
var VIA_IMPORT_CSV_COMMENT_CHAR = '#';
var _via_img_metadata = {}; // data structure to store loaded images metadata
var _via_coco_id_to_file_name = {} //data structure to get file name
var _via_img_count = 0; // count of the loaded images
var _via_canvas_regions = []; // image regions spec. in canvas space
var _via_canvas_scale = 1.0;// current scale of canvas image
var _via_image_id_list = []; // array of image id (in original order)
var _via_image_id = ''; // id={filename+length} of current image
var _via_image_index = -1; // index
var _via_current_image_filename;
var _via_current_image;
var _via_current_image_width;
var _via_current_image_height;
// image canvas
var _via_img_canvas = document.getElementById("image_canvas");
var _via_img_ctx = _via_img_canvas.getContext("2d");
var _via_reg_canvas = document.getElementById("region_canvas");
var _via_reg_ctx = _via_reg_canvas.getContext("2d");
var _via_canvas_width, _via_canvas_height;
// canvas zoom
var _via_canvas_zoom_level_index = VIA_CANVAS_DEFAULT_ZOOM_LEVEL_INDEX; // 1.0
var _via_canvas_scale_without_zoom = 1.0;
// state of the application
var _via_is_user_drawing_region = false;
var _via_current_image_loaded = false;
var _via_is_window_resized = false;
var _via_is_user_resizing_region = false;
var _via_is_user_moving_region = false;
var _via_is_user_drawing_polygon = false;
var _via_is_region_selected = false;
var _via_is_all_region_selected = false;
var _via_is_user_updating_attribute_name = false;
var _via_is_user_updating_attribute_value = false;
var _via_is_user_adding_attribute_name = false;
var _via_is_loaded_img_list_visible = false;
var _via_is_attributes_panel_visible = false;
var _via_is_reg_attr_panel_visible = false;
var _via_is_file_attr_panel_visible = false;
var _via_is_canvas_zoomed = false;
var _via_is_loading_current_image = false;
var _via_is_region_id_visible = true;
var _via_is_region_boundary_visible = true;
var _via_is_ctrl_pressed = false;
// region
var _via_current_shape = VIA_REGION_SHAPE.RECT;
var _via_current_polygon_region_id = -1;
var _via_user_sel_region_id = -1;
var _via_click_x0 = 0; var _via_click_y0 = 0;
var _via_click_x1 = 0; var _via_click_y1 = 0;
var _via_region_click_x, _via_region_click_y;
var _via_copied_image_regions = [];
var _via_region_edge = [-1, -1];
var _via_current_x = 0; var _via_current_y = 0;
// message
var _via_message_clear_timer;
// attributes
var _via_region_attributes = {};
var _via_current_update_attribute_name = "";
var _via_current_update_region_id = -1;
var _via_file_attributes = {};
var _via_visible_attr_name = '';
// persistence to local storage
var _via_is_local_storage_available = false;
var _via_is_save_ongoing = false;
// image list
var _via_reload_img_fn_list_table = true;
var _via_loaded_img_fn_list = [];
var _via_loaded_img_fn_list_file_index = [];
var _via_loaded_img_fn_list_table_html = [];
// UI html elements
var invisible_file_input = document.getElementById("invisible_file_input");
var display_area = document.getElementById("display_area");
var ui_top_panel = document.getElementById("ui_top_panel");
var canvas_panel = document.getElementById("canvas_panel");
var annotation_list_snippet = document.getElementById("annotation_list_snippet");
var annotation_textarea = document.getElementById("annotation_textarea");
var img_fn_list_panel = document.getElementById('img_fn_list_panel');
var img_fn_list = document.getElementById('img_fn_list');
var attributes_panel = document.getElementById('attributes_panel');
var annotation_data_window;
var BBOX_LINE_WIDTH = 4;
var BBOX_SELECTED_OPACITY = 0.3;
var BBOX_BOUNDARY_FILL_COLOR_ANNOTATED = "#f2f2f2";
var BBOX_BOUNDARY_FILL_COLOR_NEW = "#aaeeff";
var BBOX_BOUNDARY_LINE_COLOR = "#1a1a1a";
var BBOX_SELECTED_FILL_COLOR = "#ffffff";
// COCO flags for distinguishing between inference and annotations
var _coco_loading_ann = false;
var _coco_loading_infer = false;
var _coco_img_metadata_as_obj = {};
var _coco_next_region_id = -1;
var _coco_poly = false;
// tracking max annotation to ensure id integrity
var _coco_max_annotation_id = 0;
//
// Data structure for annotations
//
function ImageMetadata(fileref, filename, size) {
this._via_initfilename = filename;
this.size = size;
this.fileref = fileref; // image url or local file ref.
this.regions = [];
this.file_attributes = {}; // image attributes
this.base64_img_data = ''; // image data stored as base 64
this.coco_id = 0;
}
function ImageRegion() {
this.is_user_selected = false;
this.shape_attributes = {}; // region shape attributes
this.region_attributes = {}; // region attributes
this.infer = false;