@searpent/react-image-annotate 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Annotator/exampleImages_bugdemo_15_1.js +80 -0
- package/Annotator/examplePhotos_repr.js +7052 -0
- package/Annotator/index.story_bugdemo_15_1.js +882 -0
- package/Annotator/index.story_repr.js +1075 -0
- package/Editor/index.js +3 -7
- package/Editor/index_bugdemo_15_1.js +147 -0
- package/MainLayout/index.js +4 -2
- package/MainLayout/index_bugdemo_15_1.js +588 -0
- package/MetadataEditorSidebarBox/index_14_01_25.js +231 -0
- package/MetadataEditorSidebarBox/index_repr.js +271 -0
- package/package.json +1 -1
|
@@ -0,0 +1,882 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
6
|
+
import React, { useState } from "react";
|
|
7
|
+
import { storiesOf } from "@storybook/react";
|
|
8
|
+
import { action as actionAddon } from "@storybook/addon-actions";
|
|
9
|
+
import exampleImage from "../ImageCanvas/seves_desk.story.jpg";
|
|
10
|
+
import bikeImg1 from "./bike-pic.png";
|
|
11
|
+
import bikeImg2 from "./bike-pic2.png";
|
|
12
|
+
import { HotKeys } from "react-hotkeys";
|
|
13
|
+
import { defaultKeyMap } from "../ShortcutsManager";
|
|
14
|
+
import Annotator from "./";
|
|
15
|
+
import { testRegions, testRegionsBoxes } from "../ImageCanvas/index.story";
|
|
16
|
+
import photosToImages from "../utils/photosToImages";
|
|
17
|
+
import examplePhotos from "./examplePhotos";
|
|
18
|
+
import exampleImages from './exampleImages';
|
|
19
|
+
var middlewares = [function (store) {
|
|
20
|
+
return function (next) {
|
|
21
|
+
return function (action) {
|
|
22
|
+
actionAddon(action.type)(action);
|
|
23
|
+
return next(action);
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}];
|
|
27
|
+
storiesOf("Annotator", module).add("Basic", function () {
|
|
28
|
+
return /*#__PURE__*/React.createElement(Annotator, {
|
|
29
|
+
onExit: actionAddon("onExit"),
|
|
30
|
+
middlewares: middlewares,
|
|
31
|
+
labelImages: true,
|
|
32
|
+
regionClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
33
|
+
regionTagList: ["tag1", "tag2", "tag3"],
|
|
34
|
+
imageClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
35
|
+
imageTagList: ["tag1", "tag2", "tag3"],
|
|
36
|
+
images: [{
|
|
37
|
+
src: exampleImage,
|
|
38
|
+
name: "Seve's Desk",
|
|
39
|
+
regions: testRegions
|
|
40
|
+
}, {
|
|
41
|
+
src: "https://loremflickr.com/100/100/cars?lock=1",
|
|
42
|
+
name: "Frame 0036"
|
|
43
|
+
}, {
|
|
44
|
+
src: "https://loremflickr.com/100/100/cars?lock=2",
|
|
45
|
+
name: "Frame 0037"
|
|
46
|
+
}, {
|
|
47
|
+
src: "https://loremflickr.com/100/100/cars?lock=3",
|
|
48
|
+
name: "Frame 0038"
|
|
49
|
+
}]
|
|
50
|
+
});
|
|
51
|
+
}).add("Basic with onImagesChange", function () {
|
|
52
|
+
// Use exampleImages which has regions with groupId to reproduce the MainLayout bug
|
|
53
|
+
// The bug: when selectedGroupId is null but regions have groupId, filtering returns empty blocks
|
|
54
|
+
// Force selectedGroupId to null by ensuring no regions are highlighted/selected
|
|
55
|
+
var imagesToUse = exampleImages.length > 0 ? exampleImages.map(function (img) {
|
|
56
|
+
return _objectSpread({}, img, {
|
|
57
|
+
// Ensure no regions are highlighted/selected so selectedGroupId stays null
|
|
58
|
+
regions: img.regions ? img.regions.map(function (r) {
|
|
59
|
+
return _objectSpread({}, r, {
|
|
60
|
+
highlighted: false,
|
|
61
|
+
groupHighlighted: false
|
|
62
|
+
});
|
|
63
|
+
}) : [],
|
|
64
|
+
// Explicitly set selectedGroupId to null to trigger the bug
|
|
65
|
+
selectedGroupId: null
|
|
66
|
+
});
|
|
67
|
+
}) : photosToImages([examplePhotos[0]]);
|
|
68
|
+
return /*#__PURE__*/React.createElement(HotKeys, {
|
|
69
|
+
keyMap: defaultKeyMap
|
|
70
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
style: {
|
|
72
|
+
padding: "10px",
|
|
73
|
+
backgroundColor: "#fff3cd",
|
|
74
|
+
marginBottom: "10px",
|
|
75
|
+
border: "1px solid #ffc107"
|
|
76
|
+
}
|
|
77
|
+
}, /*#__PURE__*/React.createElement("strong", null, "\u26A0\uFE0F Bug Reproduction Test:"), /*#__PURE__*/React.createElement("br", null), "Images have regions with ", /*#__PURE__*/React.createElement("code", null, "groupId=\"0\""), ", but ", /*#__PURE__*/React.createElement("code", null, "selectedGroupId"), " may be null.", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("strong", null, "To see the bug:"), " Toggle \"Edit mode\" ON. If text disappears, the bug is present.", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("strong", null, "Expected after fix:"), " Text should remain visible because MainLayout now shows all blocks when selectedGroupId is null."), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Annotator, {
|
|
78
|
+
middlewares: middlewares,
|
|
79
|
+
labelImages: true,
|
|
80
|
+
regionClsList: ["author", "appendix", "photo_author", "photo_caption", "advertisement", "other_graphics", "unknown", "title", "about_author", "image", "subtitle", "interview", "table", "text", "continuation_ref", "cover_clip", "page_id", "continuation_mark", "follow_up_mark", "article_termination_mark", "page_splitting_stripe", "column_id_stripe", "prev_page_reference", "section_subcategory"],
|
|
81
|
+
help: "# Tools\n\n**E** - select tool\n\n**D** - frame tool\n\n**Ctrl** + **click frame** - edit frame\n\n**1**- **9** - change class",
|
|
82
|
+
onImagesChange: function onImagesChange(images) {
|
|
83
|
+
return console.log("[images changed to]:", images);
|
|
84
|
+
},
|
|
85
|
+
images: imagesToUse,
|
|
86
|
+
clsColors: {
|
|
87
|
+
title: "#f70202",
|
|
88
|
+
subtitle: "#ffb405",
|
|
89
|
+
text: "#14deef",
|
|
90
|
+
author: "#f8d51e",
|
|
91
|
+
appendix: "#bfede2",
|
|
92
|
+
photo_author: "#9a17bb",
|
|
93
|
+
photo_caption: "#ff84f6",
|
|
94
|
+
advertisement: "#ffb201",
|
|
95
|
+
other_graphics: "#ff5400",
|
|
96
|
+
unknown: "#bfede2",
|
|
97
|
+
about_author: "#9a17bb",
|
|
98
|
+
image: "#14deef",
|
|
99
|
+
interview: "#23b20f",
|
|
100
|
+
table: "#02b4ba",
|
|
101
|
+
continuation_ref: '#FF33CC',
|
|
102
|
+
cover_clip: '#669966',
|
|
103
|
+
page_id: '#4433AA',
|
|
104
|
+
continuation_mark: '#660066',
|
|
105
|
+
follow_up_mark: '#873e23',
|
|
106
|
+
article_termination_mark: '#873e23',
|
|
107
|
+
page_splitting_stripe: '#873e23',
|
|
108
|
+
column_id_stripe: '#873e23',
|
|
109
|
+
prev_page_reference: '#f3a864',
|
|
110
|
+
section_subcategory: '#442c55'
|
|
111
|
+
} // groupColors={[
|
|
112
|
+
// "#3853F1",
|
|
113
|
+
// "#F6E54C",
|
|
114
|
+
// "#39D33C",
|
|
115
|
+
// "#CF24CF",
|
|
116
|
+
// "#22E3ED",
|
|
117
|
+
// "#EF3029",
|
|
118
|
+
// ]}
|
|
119
|
+
,
|
|
120
|
+
enabledTools: [],
|
|
121
|
+
groupColors: ['#343434', '#989898', '#dcdcdc'],
|
|
122
|
+
onGroupSelect: function onGroupSelect(groupId) {
|
|
123
|
+
return console.log('selected groupid:', groupId);
|
|
124
|
+
},
|
|
125
|
+
hideHeader: true,
|
|
126
|
+
hideHistory: true,
|
|
127
|
+
hideNotEditingLabel: true,
|
|
128
|
+
showEditor: true,
|
|
129
|
+
showPageSelector: true,
|
|
130
|
+
albumMetadata: [{
|
|
131
|
+
key: "issueNumber",
|
|
132
|
+
value: "12"
|
|
133
|
+
}, {
|
|
134
|
+
key: "issueType",
|
|
135
|
+
value: "news"
|
|
136
|
+
}],
|
|
137
|
+
metadataConfigs: [{
|
|
138
|
+
key: "issueNumber",
|
|
139
|
+
level: "album",
|
|
140
|
+
options: []
|
|
141
|
+
}, {
|
|
142
|
+
key: "issueType",
|
|
143
|
+
level: "album",
|
|
144
|
+
options: ['news', 'magazine', 'q&a']
|
|
145
|
+
}, {
|
|
146
|
+
key: "mutation",
|
|
147
|
+
level: "photo",
|
|
148
|
+
options: ['Morava', 'Slezsko', 'Cechy']
|
|
149
|
+
}, {
|
|
150
|
+
key: "previousArticleId",
|
|
151
|
+
level: "photo_metadata-engine",
|
|
152
|
+
options: [{
|
|
153
|
+
value: "alpha",
|
|
154
|
+
label: "0 - alpha"
|
|
155
|
+
}, {
|
|
156
|
+
value: "beta",
|
|
157
|
+
label: "1 - beta"
|
|
158
|
+
}, {
|
|
159
|
+
value: "gamma",
|
|
160
|
+
label: "2 - gamma"
|
|
161
|
+
}]
|
|
162
|
+
}, {
|
|
163
|
+
key: "pageNumber",
|
|
164
|
+
level: "photo",
|
|
165
|
+
options: []
|
|
166
|
+
}, {
|
|
167
|
+
key: "articleType",
|
|
168
|
+
level: "photo_metadata-engine",
|
|
169
|
+
// options: ['news', 'ads', 'interview']
|
|
170
|
+
selectable: true,
|
|
171
|
+
options: [{
|
|
172
|
+
value: "alpha",
|
|
173
|
+
label: "0 - alpha"
|
|
174
|
+
}, {
|
|
175
|
+
value: "beta",
|
|
176
|
+
label: "1 - beta"
|
|
177
|
+
}, {
|
|
178
|
+
value: "gamma",
|
|
179
|
+
label: "2 - gamma"
|
|
180
|
+
}]
|
|
181
|
+
}, {
|
|
182
|
+
key: "section",
|
|
183
|
+
level: "photo_metadata-engine",
|
|
184
|
+
options: ['editorial', 'article', 'last page']
|
|
185
|
+
}],
|
|
186
|
+
onSelectedImageChange: function onSelectedImageChange(d) {
|
|
187
|
+
return console.log("[onSelectedImageChange] triggered:", d);
|
|
188
|
+
},
|
|
189
|
+
onExit: function onExit(s) {
|
|
190
|
+
return console.log('[onExit] triggered:', s);
|
|
191
|
+
},
|
|
192
|
+
save: /*#__PURE__*/function () {
|
|
193
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
194
|
+
var image, triggerRecalc, albumMetadata;
|
|
195
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
196
|
+
while (1) {
|
|
197
|
+
switch (_context.prev = _context.next) {
|
|
198
|
+
case 0:
|
|
199
|
+
image = _ref.image, triggerRecalc = _ref.triggerRecalc, albumMetadata = _ref.albumMetadata;
|
|
200
|
+
console.log("[SYNC] image ".concat(image.id, " saving... recalc: ").concat(triggerRecalc, " albumMetadata: ").concat(albumMetadata.length));
|
|
201
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
202
|
+
setTimeout(function () {
|
|
203
|
+
var lockedUntil = null;
|
|
204
|
+
|
|
205
|
+
if (triggerRecalc) {
|
|
206
|
+
var now = new Date();
|
|
207
|
+
now.setSeconds(now.getSeconds() + 60);
|
|
208
|
+
lockedUntil = now;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
resolve({
|
|
212
|
+
lockedUntil: lockedUntil
|
|
213
|
+
});
|
|
214
|
+
}, 3000);
|
|
215
|
+
}));
|
|
216
|
+
|
|
217
|
+
case 3:
|
|
218
|
+
case "end":
|
|
219
|
+
return _context.stop();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}, _callee);
|
|
223
|
+
}));
|
|
224
|
+
|
|
225
|
+
return function (_x) {
|
|
226
|
+
return _ref2.apply(this, arguments);
|
|
227
|
+
};
|
|
228
|
+
}(),
|
|
229
|
+
fetchImage: /*#__PURE__*/function () {
|
|
230
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
231
|
+
var imageId;
|
|
232
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
233
|
+
while (1) {
|
|
234
|
+
switch (_context2.prev = _context2.next) {
|
|
235
|
+
case 0:
|
|
236
|
+
imageId = _ref3.imageId;
|
|
237
|
+
console.log("[SYNC] image ".concat(imageId, " fetching..."));
|
|
238
|
+
return _context2.abrupt("return", new Promise(function (resolve, reject) {
|
|
239
|
+
setTimeout(function () {
|
|
240
|
+
console.log("[SYNC] image ".concat(imageId, " fetched")); // resolve({
|
|
241
|
+
// image: { ...exampleImages[0], lockedUntil: new Date().toISOString(), id: imageId }
|
|
242
|
+
// })
|
|
243
|
+
|
|
244
|
+
// resolve({
|
|
245
|
+
// image: { ...exampleImages[0], lockedUntil: new Date().toISOString(), id: imageId }
|
|
246
|
+
// })
|
|
247
|
+
resolve({
|
|
248
|
+
image: _objectSpread({}, exampleImages[0], {
|
|
249
|
+
lockedUntil: null,
|
|
250
|
+
id: imageId
|
|
251
|
+
})
|
|
252
|
+
});
|
|
253
|
+
}, 5000);
|
|
254
|
+
}));
|
|
255
|
+
|
|
256
|
+
case 3:
|
|
257
|
+
case "end":
|
|
258
|
+
return _context2.stop();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}, _callee2);
|
|
262
|
+
}));
|
|
263
|
+
|
|
264
|
+
return function (_x2) {
|
|
265
|
+
return _ref4.apply(this, arguments);
|
|
266
|
+
};
|
|
267
|
+
}()
|
|
268
|
+
}))));
|
|
269
|
+
}).add("Basic - Allow Comments", function () {
|
|
270
|
+
return /*#__PURE__*/React.createElement(Annotator, {
|
|
271
|
+
onExit: actionAddon("onExit"),
|
|
272
|
+
middlewares: middlewares,
|
|
273
|
+
labelImages: true,
|
|
274
|
+
regionClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
275
|
+
regionTagList: ["tag1", "tag2", "tag3"],
|
|
276
|
+
imageClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
277
|
+
imageTagList: ["tag1", "tag2", "tag3"],
|
|
278
|
+
images: [{
|
|
279
|
+
src: exampleImage,
|
|
280
|
+
name: "Seve's Desk",
|
|
281
|
+
regions: testRegions
|
|
282
|
+
}, {
|
|
283
|
+
src: "https://loremflickr.com/100/100/cars?lock=1",
|
|
284
|
+
name: "Frame 0036"
|
|
285
|
+
}, {
|
|
286
|
+
src: "https://loremflickr.com/100/100/cars?lock=2",
|
|
287
|
+
name: "Frame 0037"
|
|
288
|
+
}, {
|
|
289
|
+
src: "https://loremflickr.com/100/100/cars?lock=3",
|
|
290
|
+
name: "Frame 0038"
|
|
291
|
+
}],
|
|
292
|
+
allowComments: true
|
|
293
|
+
});
|
|
294
|
+
}).add("Fixed Size Container", function () {
|
|
295
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
296
|
+
style: {
|
|
297
|
+
width: 500,
|
|
298
|
+
height: 500
|
|
299
|
+
}
|
|
300
|
+
}, /*#__PURE__*/React.createElement(Annotator, {
|
|
301
|
+
onExit: actionAddon("onExit"),
|
|
302
|
+
middlewares: [function (store) {
|
|
303
|
+
return function (next) {
|
|
304
|
+
return function (action) {
|
|
305
|
+
actionAddon(action.type)(action);
|
|
306
|
+
return next(action);
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
}],
|
|
310
|
+
labelImages: true,
|
|
311
|
+
regionClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
312
|
+
regionTagList: ["tag1", "tag2", "tag3"],
|
|
313
|
+
imageClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
314
|
+
imageTagList: ["tag1", "tag2", "tag3"],
|
|
315
|
+
images: [{
|
|
316
|
+
src: exampleImage,
|
|
317
|
+
name: "Seve's Desk",
|
|
318
|
+
regions: testRegions
|
|
319
|
+
}, {
|
|
320
|
+
src: "https://loremflickr.com/100/100/cars?lock=1",
|
|
321
|
+
name: "Frame 0036"
|
|
322
|
+
}, {
|
|
323
|
+
src: "https://loremflickr.com/100/100/cars?lock=2",
|
|
324
|
+
name: "Frame 0037"
|
|
325
|
+
}, {
|
|
326
|
+
src: "https://loremflickr.com/100/100/cars?lock=3",
|
|
327
|
+
name: "Frame 0038"
|
|
328
|
+
}]
|
|
329
|
+
}));
|
|
330
|
+
}).add("Shrunk Annotator (Test Fullscreen)", function () {
|
|
331
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
332
|
+
style: {
|
|
333
|
+
padding: 100
|
|
334
|
+
}
|
|
335
|
+
}, /*#__PURE__*/React.createElement(Annotator, {
|
|
336
|
+
onExit: actionAddon("onExit"),
|
|
337
|
+
regionClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
338
|
+
regionTagList: ["tag1", "tag2", "tag3"],
|
|
339
|
+
middlewares: [function (store) {
|
|
340
|
+
return function (next) {
|
|
341
|
+
return function (action) {
|
|
342
|
+
actionAddon(action.type)(action);
|
|
343
|
+
return next(action);
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
}],
|
|
347
|
+
images: [{
|
|
348
|
+
src: exampleImage,
|
|
349
|
+
name: "Seve's Desk",
|
|
350
|
+
regions: testRegions
|
|
351
|
+
}]
|
|
352
|
+
}));
|
|
353
|
+
}).add("Annotator w/o No Region Labels or Image Labels", function () {
|
|
354
|
+
return /*#__PURE__*/React.createElement(Annotator, {
|
|
355
|
+
onExit: actionAddon("onExit"),
|
|
356
|
+
middlewares: middlewares,
|
|
357
|
+
images: [{
|
|
358
|
+
src: exampleImage,
|
|
359
|
+
name: "Seve's Desk",
|
|
360
|
+
regions: testRegions
|
|
361
|
+
}]
|
|
362
|
+
});
|
|
363
|
+
}).add("Annotator with no enabled tools", function () {
|
|
364
|
+
return /*#__PURE__*/React.createElement(Annotator, {
|
|
365
|
+
onExit: actionAddon("onExit"),
|
|
366
|
+
enabledTools: [],
|
|
367
|
+
showTags: false,
|
|
368
|
+
middlewares: middlewares,
|
|
369
|
+
images: [{
|
|
370
|
+
src: exampleImage,
|
|
371
|
+
name: "Seve's Desk",
|
|
372
|
+
regions: testRegions
|
|
373
|
+
}]
|
|
374
|
+
});
|
|
375
|
+
}).add("Bounding Box Annotator with output to console.log", function () {
|
|
376
|
+
return /*#__PURE__*/React.createElement(Annotator, {
|
|
377
|
+
onExit: function onExit(out) {
|
|
378
|
+
window.lastOutput = out;
|
|
379
|
+
console.log(out);
|
|
380
|
+
},
|
|
381
|
+
taskDescription: "## Annotate Hands\nDraw a bounding box around each hand.",
|
|
382
|
+
enabledTools: ["select", "create-box"],
|
|
383
|
+
regionClsList: ["Hand", "Face"],
|
|
384
|
+
regionTagList: ["Open Pinch", "Closed Pinch", "In Frame"],
|
|
385
|
+
showTags: false,
|
|
386
|
+
images: [{
|
|
387
|
+
src: "https://s3.amazonaws.com/jobstorage.workaround.online/Atheer/video-frames/VID_20190111_161054.mp4_frame017.png",
|
|
388
|
+
name: "Bounding Box Test",
|
|
389
|
+
regions: []
|
|
390
|
+
}, {
|
|
391
|
+
src: "https://s3.amazonaws.com/jobstorage.workaround.online/Atheer/video-frames/VID_20190111_161054.mp4_frame001.png",
|
|
392
|
+
name: "Bounding Box Test",
|
|
393
|
+
regions: []
|
|
394
|
+
}]
|
|
395
|
+
});
|
|
396
|
+
}).add("Bounding Box Annotator with allowed area", function () {
|
|
397
|
+
return /*#__PURE__*/React.createElement(Annotator, {
|
|
398
|
+
taskDescription: "## Annotate Hands\nDraw a bounding box around each hand.",
|
|
399
|
+
enabledTools: ["select", "create-box"],
|
|
400
|
+
regionClsList: ["Hand", "Face"],
|
|
401
|
+
regionTagList: ["Open Pinch", "Closed Pinch", "In Frame"],
|
|
402
|
+
showTags: false,
|
|
403
|
+
allowedArea: {
|
|
404
|
+
x: 0,
|
|
405
|
+
y: 0.6,
|
|
406
|
+
w: 0.3,
|
|
407
|
+
h: 0.3
|
|
408
|
+
},
|
|
409
|
+
images: [{
|
|
410
|
+
src: "https://s3.amazonaws.com/jobstorage.workaround.online/Atheer/video-frames/VID_20190111_161054.mp4_frame017.png",
|
|
411
|
+
name: "Bounding Box Test",
|
|
412
|
+
regions: []
|
|
413
|
+
}]
|
|
414
|
+
});
|
|
415
|
+
}).add("Car Annotation", function () {
|
|
416
|
+
return /*#__PURE__*/React.createElement(Annotator, _defineProperty({
|
|
417
|
+
onExit: actionAddon("onExit"),
|
|
418
|
+
middlewares: middlewares,
|
|
419
|
+
labelImages: true,
|
|
420
|
+
regionClsList: ["Car", "Sign", "Construction Barrier"],
|
|
421
|
+
regionTagList: ["Moving", "Stopped", "Obstacle"],
|
|
422
|
+
imageClsList: ["On Street", "Sidewalk", "Other"] // imageTagList={["tag1", "tag2", "tag3"]}
|
|
423
|
+
,
|
|
424
|
+
images: [{
|
|
425
|
+
src: bikeImg1,
|
|
426
|
+
name: "Frame 03021",
|
|
427
|
+
regions: [{
|
|
428
|
+
cls: "Car",
|
|
429
|
+
color: "hsl(82,100%,50%)",
|
|
430
|
+
h: 0.45921666772960146,
|
|
431
|
+
w: 0.3932156342484836,
|
|
432
|
+
x: 0.6302148980776354,
|
|
433
|
+
y: 0.5559504689545722,
|
|
434
|
+
type: "box",
|
|
435
|
+
id: "8776160642957009",
|
|
436
|
+
tags: ["Stopped"],
|
|
437
|
+
highlighted: false,
|
|
438
|
+
editingLabels: false
|
|
439
|
+
}, {
|
|
440
|
+
cls: "Car",
|
|
441
|
+
color: "hsl(264,100%,50%)",
|
|
442
|
+
type: "box",
|
|
443
|
+
id: "885140028730734",
|
|
444
|
+
tags: ["Moving"],
|
|
445
|
+
w: 0.2627711048576583,
|
|
446
|
+
x: 0.20751775748638238,
|
|
447
|
+
y: 0.5566583219431673,
|
|
448
|
+
h: 0.268717618171478,
|
|
449
|
+
highlighted: false,
|
|
450
|
+
editingLabels: false
|
|
451
|
+
}, {
|
|
452
|
+
cls: "Car",
|
|
453
|
+
color: "hsl(127,100%,50%)",
|
|
454
|
+
w: 0.033016094117647055,
|
|
455
|
+
x: 0.5051247779336334,
|
|
456
|
+
y: 0.5396378545840628,
|
|
457
|
+
h: 0.03423999999999994,
|
|
458
|
+
type: "box",
|
|
459
|
+
id: "5952553512262024",
|
|
460
|
+
tags: ["Stopped"],
|
|
461
|
+
highlighted: false,
|
|
462
|
+
editingLabels: false
|
|
463
|
+
}, {
|
|
464
|
+
type: "box",
|
|
465
|
+
x: 0.7847296794208894,
|
|
466
|
+
y: 0.3635007199404308,
|
|
467
|
+
w: 0.04871147880041349,
|
|
468
|
+
h: 0.10995961095800888,
|
|
469
|
+
highlighted: true,
|
|
470
|
+
editingLabels: false,
|
|
471
|
+
color: "hsl(268,100%,50%)",
|
|
472
|
+
id: "5647593040225252",
|
|
473
|
+
cls: "Sign"
|
|
474
|
+
}]
|
|
475
|
+
}, {
|
|
476
|
+
src: bikeImg2,
|
|
477
|
+
name: "Frame 03022",
|
|
478
|
+
regions: [{
|
|
479
|
+
type: "box",
|
|
480
|
+
x: 0.12226982552783494,
|
|
481
|
+
y: 0.5578947368421052,
|
|
482
|
+
w: 0.3301518695958121,
|
|
483
|
+
h: 0.33562583001232194,
|
|
484
|
+
highlighted: false,
|
|
485
|
+
editingLabels: false,
|
|
486
|
+
color: "hsl(171,100%,50%)",
|
|
487
|
+
id: "014393439034159128",
|
|
488
|
+
cls: "Car",
|
|
489
|
+
tags: ["Stopped"]
|
|
490
|
+
}, {
|
|
491
|
+
type: "box",
|
|
492
|
+
x: 0.5018477698901193,
|
|
493
|
+
y: 0.5954194079501558,
|
|
494
|
+
w: 0.07194249496837657,
|
|
495
|
+
h: 0.06826906557009338,
|
|
496
|
+
highlighted: false,
|
|
497
|
+
editingLabels: false,
|
|
498
|
+
color: "hsl(17,100%,50%)",
|
|
499
|
+
id: "02954614542034717",
|
|
500
|
+
cls: "Car",
|
|
501
|
+
tags: ["Moving"]
|
|
502
|
+
}, {
|
|
503
|
+
type: "box",
|
|
504
|
+
x: 0.6483083881082046,
|
|
505
|
+
y: 0.6217109311709718,
|
|
506
|
+
w: 0.08786544324705947,
|
|
507
|
+
h: 0.20450608002345438,
|
|
508
|
+
highlighted: true,
|
|
509
|
+
editingLabels: true,
|
|
510
|
+
color: "hsl(337,100%,50%)",
|
|
511
|
+
id: "9124138360972984",
|
|
512
|
+
cls: "Construction Barrier",
|
|
513
|
+
tags: ["Obstacle"]
|
|
514
|
+
}, {
|
|
515
|
+
type: "box",
|
|
516
|
+
x: 0.7628671305695606,
|
|
517
|
+
y: 0.6299511028935285,
|
|
518
|
+
w: 0.12734928166820647,
|
|
519
|
+
h: 0.2689292407634438,
|
|
520
|
+
highlighted: false,
|
|
521
|
+
editingLabels: false,
|
|
522
|
+
color: "hsl(89,100%,50%)",
|
|
523
|
+
id: "5960600741979638",
|
|
524
|
+
cls: "Construction Barrier"
|
|
525
|
+
}, {
|
|
526
|
+
type: "box",
|
|
527
|
+
x: 0.5871362440754417,
|
|
528
|
+
y: 0.6232091442114366,
|
|
529
|
+
w: 0.06562102723514573,
|
|
530
|
+
h: 0.15281773012741662,
|
|
531
|
+
highlighted: false,
|
|
532
|
+
editingLabels: false,
|
|
533
|
+
color: "hsl(326,100%,50%)",
|
|
534
|
+
id: "7955287536996538",
|
|
535
|
+
cls: "Construction Barrier"
|
|
536
|
+
}, {
|
|
537
|
+
type: "box",
|
|
538
|
+
x: 0.42943330004934643,
|
|
539
|
+
y: 0.6054718359824862,
|
|
540
|
+
w: 0.053210066743122564,
|
|
541
|
+
h: 0.054984658299147116,
|
|
542
|
+
highlighted: false,
|
|
543
|
+
editingLabels: false,
|
|
544
|
+
color: "hsl(66,100%,50%)",
|
|
545
|
+
id: "49573139861381166",
|
|
546
|
+
cls: "Car",
|
|
547
|
+
tags: ["Stopped"]
|
|
548
|
+
}]
|
|
549
|
+
}]
|
|
550
|
+
}, "onExit", function onExit(out) {
|
|
551
|
+
window.lastOutput = out;
|
|
552
|
+
console.log(JSON.stringify(out.images));
|
|
553
|
+
}));
|
|
554
|
+
}).add("Annotator blocks scroll from propagating", function () {
|
|
555
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
556
|
+
style: {
|
|
557
|
+
height: "200vh"
|
|
558
|
+
}
|
|
559
|
+
}, /*#__PURE__*/React.createElement(Annotator, {
|
|
560
|
+
onExit: actionAddon("onExit"),
|
|
561
|
+
showTags: false,
|
|
562
|
+
middlewares: [function (store) {
|
|
563
|
+
return function (next) {
|
|
564
|
+
return function (action) {
|
|
565
|
+
actionAddon(action.type)(action);
|
|
566
|
+
return next(action);
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
}],
|
|
570
|
+
images: [{
|
|
571
|
+
src: exampleImage,
|
|
572
|
+
name: "Seve's Desk",
|
|
573
|
+
regions: testRegions
|
|
574
|
+
}]
|
|
575
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
576
|
+
style: {
|
|
577
|
+
color: "red"
|
|
578
|
+
}
|
|
579
|
+
}, "You shouldn't be able to see this"));
|
|
580
|
+
}).add("Annotator should not expand beyond parent", function () {
|
|
581
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
582
|
+
style: {
|
|
583
|
+
width: "100vw",
|
|
584
|
+
height: "100vh",
|
|
585
|
+
padding: 100,
|
|
586
|
+
boxSizing: "border-box"
|
|
587
|
+
}
|
|
588
|
+
}, /*#__PURE__*/React.createElement(Annotator, {
|
|
589
|
+
onExit: actionAddon("onExit"),
|
|
590
|
+
showTags: false,
|
|
591
|
+
middlewares: [function (store) {
|
|
592
|
+
return function (next) {
|
|
593
|
+
return function (action) {
|
|
594
|
+
actionAddon(action.type)(action);
|
|
595
|
+
return next(action);
|
|
596
|
+
};
|
|
597
|
+
};
|
|
598
|
+
}],
|
|
599
|
+
images: [{
|
|
600
|
+
src: exampleImage,
|
|
601
|
+
name: "Seve's Desk",
|
|
602
|
+
regions: testRegions
|
|
603
|
+
}]
|
|
604
|
+
}));
|
|
605
|
+
}).add("Video with frames as each image", function () {
|
|
606
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
607
|
+
style: {
|
|
608
|
+
width: "100vw",
|
|
609
|
+
height: "100vh",
|
|
610
|
+
boxSizing: "border-box"
|
|
611
|
+
}
|
|
612
|
+
}, /*#__PURE__*/React.createElement(Annotator, {
|
|
613
|
+
onExit: actionAddon("onExit"),
|
|
614
|
+
showTags: false,
|
|
615
|
+
middlewares: [function (store) {
|
|
616
|
+
return function (next) {
|
|
617
|
+
return function (action) {
|
|
618
|
+
actionAddon(action.type)(action);
|
|
619
|
+
return next(action);
|
|
620
|
+
};
|
|
621
|
+
};
|
|
622
|
+
}],
|
|
623
|
+
images: [{
|
|
624
|
+
src: "https://s3.amazonaws.com/asset.workaround.online/SampleVideo_1280x720_1mb.mp4",
|
|
625
|
+
frameTime: 0,
|
|
626
|
+
name: "Frame 1"
|
|
627
|
+
}, {
|
|
628
|
+
src: "https://s3.amazonaws.com/asset.workaround.online/SampleVideo_1280x720_1mb.mp4",
|
|
629
|
+
frameTime: 4500,
|
|
630
|
+
name: "Frame 2"
|
|
631
|
+
}]
|
|
632
|
+
}));
|
|
633
|
+
}).add("Keyframe video", function () {
|
|
634
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
635
|
+
style: {
|
|
636
|
+
width: "100vw",
|
|
637
|
+
height: "100vh",
|
|
638
|
+
boxSizing: "border-box"
|
|
639
|
+
}
|
|
640
|
+
}, /*#__PURE__*/React.createElement(Annotator, {
|
|
641
|
+
onExit: function onExit() {
|
|
642
|
+
var _console;
|
|
643
|
+
|
|
644
|
+
(_console = console).log.apply(_console, arguments);
|
|
645
|
+
|
|
646
|
+
actionAddon("onExit").apply(void 0, arguments);
|
|
647
|
+
},
|
|
648
|
+
showTags: true,
|
|
649
|
+
videoSrc: "https://s3.amazonaws.com/asset.workaround.online/SampleVideo_1280x720_1mb.mp4",
|
|
650
|
+
videoTime: 1000,
|
|
651
|
+
keyframes: {
|
|
652
|
+
0: {
|
|
653
|
+
regions: [{
|
|
654
|
+
type: "point",
|
|
655
|
+
x: 0.1608187134502924,
|
|
656
|
+
y: 0.5769980506822612,
|
|
657
|
+
highlighted: true,
|
|
658
|
+
editingLabels: false,
|
|
659
|
+
color: "hsl(238,100%,50%)",
|
|
660
|
+
id: "9995495728521284"
|
|
661
|
+
}, {
|
|
662
|
+
type: "box",
|
|
663
|
+
x: 0.089171974522293,
|
|
664
|
+
y: 0.36801132342533616,
|
|
665
|
+
w: 0.30573248407643316,
|
|
666
|
+
h: 0.4170794998820476,
|
|
667
|
+
highlighted: true,
|
|
668
|
+
editingLabels: false,
|
|
669
|
+
color: "hsl(263,100%,50%)",
|
|
670
|
+
id: "04858393322065635"
|
|
671
|
+
}]
|
|
672
|
+
},
|
|
673
|
+
3333: {
|
|
674
|
+
regions: [{
|
|
675
|
+
type: "point",
|
|
676
|
+
x: 0.1608187134502924,
|
|
677
|
+
y: 0.5769980506822612,
|
|
678
|
+
highlighted: true,
|
|
679
|
+
editingLabels: false,
|
|
680
|
+
color: "hsl(238,100%,50%)",
|
|
681
|
+
id: "9995495728521284"
|
|
682
|
+
}, {
|
|
683
|
+
type: "box",
|
|
684
|
+
x: 0.14861995753715496,
|
|
685
|
+
y: 0.0934182590233546,
|
|
686
|
+
w: 0.3163481953290871,
|
|
687
|
+
h: 0.7596131163010142,
|
|
688
|
+
highlighted: true,
|
|
689
|
+
editingLabels: false,
|
|
690
|
+
color: "hsl(263,100%,50%)",
|
|
691
|
+
id: "04858393322065635"
|
|
692
|
+
}]
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}));
|
|
696
|
+
}).add("Override Next/Prev Button Handling", function () {
|
|
697
|
+
var images = [exampleImage, "https://loremflickr.com/100/100/cars?lock=1", "https://loremflickr.com/100/100/cars?lock=2"];
|
|
698
|
+
|
|
699
|
+
var _useState = useState(0),
|
|
700
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
701
|
+
selectedImageIndex = _useState2[0],
|
|
702
|
+
changeSelectedImageIndex = _useState2[1];
|
|
703
|
+
|
|
704
|
+
return /*#__PURE__*/React.createElement(Annotator, {
|
|
705
|
+
onExit: actionAddon("onExit"),
|
|
706
|
+
onNextImage: function onNextImage() {
|
|
707
|
+
actionAddon("onNextImage")();
|
|
708
|
+
changeSelectedImageIndex((selectedImageIndex + 1) % 3);
|
|
709
|
+
},
|
|
710
|
+
onPrevImage: function onPrevImage() {
|
|
711
|
+
actionAddon("onPrevImage")();
|
|
712
|
+
changeSelectedImageIndex((selectedImageIndex - 1 + 3) % 3);
|
|
713
|
+
},
|
|
714
|
+
labelImages: true,
|
|
715
|
+
selectedImage: images[selectedImageIndex],
|
|
716
|
+
regionClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
717
|
+
imageClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
718
|
+
images: [{
|
|
719
|
+
src: exampleImage,
|
|
720
|
+
name: "Seve's Desk"
|
|
721
|
+
}, {
|
|
722
|
+
src: images[1],
|
|
723
|
+
name: "Frame 0036"
|
|
724
|
+
}, {
|
|
725
|
+
src: images[2],
|
|
726
|
+
name: "Frame 0037"
|
|
727
|
+
}]
|
|
728
|
+
});
|
|
729
|
+
}).add("Override RegionEditLabel", function () {
|
|
730
|
+
var images = [exampleImage, "https://loremflickr.com/100/100/cars?lock=1", "https://loremflickr.com/100/100/cars?lock=2"];
|
|
731
|
+
|
|
732
|
+
var NewRegionEditLabel = function NewRegionEditLabel(_ref5) {
|
|
733
|
+
var region = _ref5.region,
|
|
734
|
+
editing = _ref5.editing,
|
|
735
|
+
onDelete = _ref5.onDelete,
|
|
736
|
+
onChange = _ref5.onChange,
|
|
737
|
+
onClose = _ref5.onClose,
|
|
738
|
+
onOpen = _ref5.onOpen;
|
|
739
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
740
|
+
style: {
|
|
741
|
+
backgroundColor: "white"
|
|
742
|
+
}
|
|
743
|
+
}, "I'm the closed part", /*#__PURE__*/React.createElement("div", {
|
|
744
|
+
style: {
|
|
745
|
+
display: editing ? "block" : "none"
|
|
746
|
+
}
|
|
747
|
+
}, "I'm the part that shows when it's being edited!", /*#__PURE__*/React.createElement("button", {
|
|
748
|
+
onClick: function onClick() {
|
|
749
|
+
return onDelete(region);
|
|
750
|
+
}
|
|
751
|
+
}, "Delete This Region"), /*#__PURE__*/React.createElement("button", {
|
|
752
|
+
onClick: function onClick() {
|
|
753
|
+
return onChange(_objectSpread({}, region, {
|
|
754
|
+
cls: "awesome-value"
|
|
755
|
+
}));
|
|
756
|
+
}
|
|
757
|
+
}, "Set Classification to \"awesome-value\""), /*#__PURE__*/React.createElement("button", {
|
|
758
|
+
onClick: function onClick() {
|
|
759
|
+
return onClose(region);
|
|
760
|
+
}
|
|
761
|
+
}, "Close the edit mode")));
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
return /*#__PURE__*/React.createElement(Annotator, {
|
|
765
|
+
onExit: actionAddon("onExit"),
|
|
766
|
+
labelImages: true,
|
|
767
|
+
selectedImage: images[0],
|
|
768
|
+
RegionEditLabel: NewRegionEditLabel,
|
|
769
|
+
images: [{
|
|
770
|
+
src: exampleImage,
|
|
771
|
+
name: "Seve's Desk"
|
|
772
|
+
}, {
|
|
773
|
+
src: images[1],
|
|
774
|
+
name: "Frame 0036"
|
|
775
|
+
}, {
|
|
776
|
+
src: images[2],
|
|
777
|
+
name: "Frame 0037"
|
|
778
|
+
}]
|
|
779
|
+
});
|
|
780
|
+
}).add("Two on sample page w/ hotkeys", function () {
|
|
781
|
+
return /*#__PURE__*/React.createElement(HotKeys, {
|
|
782
|
+
keyMap: defaultKeyMap
|
|
783
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
784
|
+
style: {
|
|
785
|
+
height: 600
|
|
786
|
+
}
|
|
787
|
+
}, /*#__PURE__*/React.createElement(Annotator, {
|
|
788
|
+
onExit: actionAddon("onExit"),
|
|
789
|
+
regionClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
790
|
+
imageClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
791
|
+
middlewares: [function (store) {
|
|
792
|
+
return function (next) {
|
|
793
|
+
return function (action) {
|
|
794
|
+
actionAddon(action.type)(action);
|
|
795
|
+
return next(action);
|
|
796
|
+
};
|
|
797
|
+
};
|
|
798
|
+
}],
|
|
799
|
+
images: [{
|
|
800
|
+
src: exampleImage,
|
|
801
|
+
name: "Seve's Desk",
|
|
802
|
+
regions: testRegions
|
|
803
|
+
}]
|
|
804
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
805
|
+
style: {
|
|
806
|
+
height: 600
|
|
807
|
+
}
|
|
808
|
+
}, /*#__PURE__*/React.createElement(Annotator, {
|
|
809
|
+
onExit: actionAddon("onExit"),
|
|
810
|
+
middlewares: [function (store) {
|
|
811
|
+
return function (next) {
|
|
812
|
+
return function (action) {
|
|
813
|
+
actionAddon(action.type)(action);
|
|
814
|
+
return next(action);
|
|
815
|
+
};
|
|
816
|
+
};
|
|
817
|
+
}],
|
|
818
|
+
images: [{
|
|
819
|
+
src: exampleImage,
|
|
820
|
+
name: "Seve's Desk",
|
|
821
|
+
regions: testRegions
|
|
822
|
+
}]
|
|
823
|
+
}))));
|
|
824
|
+
}).add("CORs Error (Pixel Segmentation)", function () {
|
|
825
|
+
return /*#__PURE__*/React.createElement(Annotator, {
|
|
826
|
+
onExit: actionAddon("onExit"),
|
|
827
|
+
middlewares: middlewares,
|
|
828
|
+
labelImages: true,
|
|
829
|
+
fullImageSegmentationMode: true,
|
|
830
|
+
regionClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
831
|
+
images: [{
|
|
832
|
+
src: "https://placebear.com/200/300",
|
|
833
|
+
name: "Frame 0036"
|
|
834
|
+
}]
|
|
835
|
+
});
|
|
836
|
+
}).add("Modify Allowed Area", function () {
|
|
837
|
+
return /*#__PURE__*/React.createElement(Annotator, {
|
|
838
|
+
onExit: actionAddon("onExit"),
|
|
839
|
+
middlewares: middlewares,
|
|
840
|
+
labelImages: true,
|
|
841
|
+
fullImageSegmentationMode: true,
|
|
842
|
+
allowedArea: {
|
|
843
|
+
x: 0,
|
|
844
|
+
y: 0.6,
|
|
845
|
+
w: 0.3,
|
|
846
|
+
h: 0.3
|
|
847
|
+
},
|
|
848
|
+
enabledTools: ["modify-allowed-area"],
|
|
849
|
+
regionClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
850
|
+
images: [{
|
|
851
|
+
src: exampleImage,
|
|
852
|
+
name: "Frame 0036"
|
|
853
|
+
}]
|
|
854
|
+
});
|
|
855
|
+
}).add("Hide Next, Hide Header Text", function () {
|
|
856
|
+
return /*#__PURE__*/React.createElement(Annotator, {
|
|
857
|
+
onExit: actionAddon("onExit"),
|
|
858
|
+
labelImages: true,
|
|
859
|
+
hideNext: true,
|
|
860
|
+
hideHeaderText: true,
|
|
861
|
+
fullImageSegmentationMode: true,
|
|
862
|
+
enabledTools: ["modify-allowed-area"],
|
|
863
|
+
regionClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
864
|
+
images: [{
|
|
865
|
+
src: exampleImage,
|
|
866
|
+
name: "Frame 0036"
|
|
867
|
+
}]
|
|
868
|
+
});
|
|
869
|
+
}).add("Hide Header", function () {
|
|
870
|
+
return /*#__PURE__*/React.createElement(Annotator, {
|
|
871
|
+
onExit: actionAddon("onExit"),
|
|
872
|
+
labelImages: true,
|
|
873
|
+
hideHeader: true,
|
|
874
|
+
fullImageSegmentationMode: true,
|
|
875
|
+
enabledTools: ["modify-allowed-area"],
|
|
876
|
+
regionClsList: ["Alpha", "Beta", "Charlie", "Delta"],
|
|
877
|
+
images: [{
|
|
878
|
+
src: exampleImage,
|
|
879
|
+
name: "Frame 0036"
|
|
880
|
+
}]
|
|
881
|
+
});
|
|
882
|
+
});
|