@searpent/react-image-annotate 2.0.3 → 2.0.4
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/.babelrc +6 -0
- package/.env +1 -0
- package/.flowconfig +2 -0
- package/.github/workflows/release-on-master.yml +32 -0
- package/.github/workflows/test.yml +16 -0
- package/.prettierrc +3 -0
- package/.releaserc.js +18 -0
- package/.storybook/addons.js +2 -0
- package/.storybook/config.js +16 -0
- package/LICENSE +21 -0
- package/package.json +4 -1
- package/public/favicon.ico +0 -0
- package/public/index.html +38 -0
- package/src/Annotator/bike-pic.png +0 -0
- package/src/Annotator/bike-pic2.png +0 -0
- package/src/Annotator/dab-keyframes.story.json +1 -0
- package/src/Annotator/examplePhotos.js +7601 -0
- package/src/Annotator/index.js +291 -0
- package/src/Annotator/index.story.js +807 -0
- package/src/Annotator/poses.story.js +150 -0
- package/src/Annotator/reducers/combine-reducers.js +7 -0
- package/src/Annotator/reducers/convert-expanding-line-to-polygon.js +53 -0
- package/{Annotator → src/Annotator}/reducers/fix-twisted.js +5 -3
- package/src/Annotator/reducers/general-reducer.js +996 -0
- package/src/Annotator/reducers/get-active-image.js +21 -0
- package/src/Annotator/reducers/get-implied-video-regions.js +115 -0
- package/src/Annotator/reducers/history-handler.js +60 -0
- package/src/Annotator/reducers/image-reducer.js +23 -0
- package/src/Annotator/reducers/video-reducer.js +85 -0
- package/src/Annotator/video.story.js +51 -0
- package/src/ClassSelectionMenu/index.js +108 -0
- package/src/Crosshairs/index.js +64 -0
- package/src/DebugSidebarBox/index.js +36 -0
- package/src/DemoSite/Editor.js +235 -0
- package/src/DemoSite/ErrorBoundaryDialog.js +34 -0
- package/src/DemoSite/index.js +41 -0
- package/src/DemoSite/index.story.js +10 -0
- package/src/DemoSite/simple-segmentation-example.json +572 -0
- package/src/Editor/annotation-plugin/annotation.css +46 -0
- package/src/Editor/annotation-plugin/annotation.js +515 -0
- package/src/Editor/index.js +24 -0
- package/src/Editor/tools.js +6 -0
- package/src/FullImageSegmentationAnnotator/hard1.story.jpg +0 -0
- package/src/FullImageSegmentationAnnotator/hard2.story.jpg +0 -0
- package/src/FullImageSegmentationAnnotator/hard3.story.jpg +0 -0
- package/src/FullImageSegmentationAnnotator/index.js +7 -0
- package/src/FullImageSegmentationAnnotator/index.story.js +177 -0
- package/src/FullImageSegmentationAnnotator/orange.story.png +0 -0
- package/src/GroupSelectorSidebarBox/index.js +48 -0
- package/src/HighlightBox/index.js +143 -0
- package/src/HistorySidebarBox/index.js +78 -0
- package/src/ImageCanvas/dancing-man.story.jpg +0 -0
- package/src/ImageCanvas/index.js +494 -0
- package/src/ImageCanvas/index.story.js +314 -0
- package/src/ImageCanvas/mouse_mask.story.png +0 -0
- package/src/ImageCanvas/region-tools.js +171 -0
- package/src/ImageCanvas/seves_desk.story.jpg +0 -0
- package/{ImageCanvas → src/ImageCanvas}/styles.js +8 -12
- package/src/ImageCanvas/use-mouse.js +168 -0
- package/src/ImageCanvas/use-project-box.js +23 -0
- package/src/ImageCanvas/use-wasd-mode.js +50 -0
- package/src/ImageMask/index.js +127 -0
- package/src/ImageMask/load-image.js +32 -0
- package/src/ImageSelectorSidebarBox/index.js +54 -0
- package/src/KeyframeTimeline/get-time-string.js +25 -0
- package/src/KeyframeTimeline/index.js +223 -0
- package/src/KeyframesSelectorSidebarBox/index.js +93 -0
- package/src/LandingPage/content.md +57 -0
- package/src/LandingPage/github-markdown.css +964 -0
- package/src/LandingPage/index.js +147 -0
- package/src/MainLayout/icon-dictionary.js +79 -0
- package/src/MainLayout/index.js +510 -0
- package/src/MainLayout/index.story.js +240 -0
- package/{MainLayout → src/MainLayout}/styles.js +7 -6
- package/src/MainLayout/types.js +164 -0
- package/src/MainLayout/use-implied-video-regions.js +17 -0
- package/src/MetadataEditorSidebarBox/index.js +98 -0
- package/src/PageSelector/index.js +76 -0
- package/src/PageSelector/page-selector.css +69 -0
- package/src/PointDistances/index.js +90 -0
- package/src/PreventScrollToParents/index.js +48 -0
- package/src/PreventScrollToParents/index.story.js +23 -0
- package/src/RegionLabel/index.js +222 -0
- package/{RegionLabel → src/RegionLabel}/styles.js +15 -12
- package/src/RegionSelectAndTransformBoxes/index.js +234 -0
- package/src/RegionSelectorSidebarBox/index.js +216 -0
- package/{RegionSelectorSidebarBox → src/RegionSelectorSidebarBox}/styles.js +14 -13
- package/src/RegionShapes/index.js +254 -0
- package/src/RegionTags/index.js +134 -0
- package/src/SettingsDialog/index.js +58 -0
- package/src/SettingsProvider/index.js +48 -0
- package/src/Shortcuts/ShortcutField.js +44 -0
- package/src/Shortcuts/index.js +129 -0
- package/src/ShortcutsManager/index.js +162 -0
- package/src/Sidebar/index.js +117 -0
- package/src/SidebarBoxContainer/index.js +93 -0
- package/src/SmallToolButton/index.js +57 -0
- package/src/TagsSidebarBox/index.js +93 -0
- package/src/TaskDescriptionSidebarBox/index.js +43 -0
- package/src/Theme/index.js +36 -0
- package/src/VideoOrImageCanvasBackground/index.js +170 -0
- package/src/colors.js +32 -0
- package/src/hooks/use-colors.js +74 -0
- package/src/hooks/use-event-callback.js +11 -0
- package/src/hooks/use-exclude-pattern.js +27 -0
- package/src/hooks/use-load-image.js +21 -0
- package/src/hooks/use-window-size.js +46 -0
- package/{hooks → src/hooks}/xpattern.js +1 -1
- package/src/hooks/xpattern.png +0 -0
- package/src/index.js +18 -0
- package/src/lib.js +7 -0
- package/src/screenshot.png +0 -0
- package/src/site.css +5 -0
- package/src/stories.js +2 -0
- package/src/utils/filter-only-unique.js +5 -0
- package/src/utils/get-from-local-storage.js +7 -0
- package/src/utils/get-hotkey-help-text.js +11 -0
- package/src/utils/get-landmarks-with-transform.js +23 -0
- package/src/utils/photosToImages.js +40 -0
- package/src/utils/regions-to-blocks.js +14 -0
- package/src/utils/set-in-local-storage.js +6 -0
- package/Annotator/index.js +0 -169
- package/Annotator/reducers/combine-reducers.js +0 -14
- package/Annotator/reducers/convert-expanding-line-to-polygon.js +0 -73
- package/Annotator/reducers/general-reducer.js +0 -1058
- package/Annotator/reducers/get-active-image.js +0 -27
- package/Annotator/reducers/get-implied-video-regions.js +0 -180
- package/Annotator/reducers/history-handler.js +0 -38
- package/Annotator/reducers/image-reducer.js +0 -20
- package/Annotator/reducers/video-reducer.js +0 -88
- package/ClassSelectionMenu/index.js +0 -135
- package/Crosshairs/index.js +0 -53
- package/DebugSidebarBox/index.js +0 -20
- package/DemoSite/Editor.js +0 -194
- package/DemoSite/ErrorBoundaryDialog.js +0 -64
- package/DemoSite/index.js +0 -40
- package/FullImageSegmentationAnnotator/index.js +0 -7
- package/GroupSelectorSidebarBox/index.js +0 -63
- package/HighlightBox/index.js +0 -99
- package/HistorySidebarBox/index.js +0 -71
- package/ImageCanvas/index.js +0 -424
- package/ImageCanvas/region-tools.js +0 -165
- package/ImageCanvas/use-mouse.js +0 -180
- package/ImageCanvas/use-project-box.js +0 -27
- package/ImageCanvas/use-wasd-mode.js +0 -62
- package/ImageMask/index.js +0 -133
- package/ImageMask/load-image.js +0 -25
- package/ImageSelectorSidebarBox/index.js +0 -60
- package/KeyframeTimeline/get-time-string.js +0 -27
- package/KeyframeTimeline/index.js +0 -233
- package/KeyframesSelectorSidebarBox/index.js +0 -93
- package/LandingPage/index.js +0 -159
- package/MainLayout/icon-dictionary.js +0 -104
- package/MainLayout/index.js +0 -366
- package/MainLayout/types.js +0 -0
- package/MainLayout/use-implied-video-regions.js +0 -13
- package/PointDistances/index.js +0 -73
- package/PreventScrollToParents/index.js +0 -51
- package/RegionLabel/index.js +0 -191
- package/RegionSelectAndTransformBoxes/index.js +0 -167
- package/RegionSelectorSidebarBox/index.js +0 -248
- package/RegionShapes/index.js +0 -274
- package/RegionTags/index.js +0 -138
- package/SettingsDialog/index.js +0 -52
- package/SettingsProvider/index.js +0 -53
- package/Shortcuts/ShortcutField.js +0 -46
- package/Shortcuts/index.js +0 -133
- package/ShortcutsManager/index.js +0 -155
- package/Sidebar/index.js +0 -69
- package/SidebarBoxContainer/index.js +0 -93
- package/SmallToolButton/index.js +0 -42
- package/TagsSidebarBox/index.js +0 -105
- package/TaskDescriptionSidebarBox/index.js +0 -58
- package/Theme/index.js +0 -30
- package/VideoOrImageCanvasBackground/index.js +0 -151
- package/colors.js +0 -14
- package/hooks/use-event-callback.js +0 -10
- package/hooks/use-exclude-pattern.js +0 -24
- package/hooks/use-load-image.js +0 -26
- package/hooks/use-window-size.js +0 -46
- package/index.js +0 -3
- package/lib.js +0 -3
- package/stories.js +0 -5
- package/utils/get-from-local-storage.js +0 -7
- package/utils/get-hotkey-help-text.js +0 -9
- package/utils/get-landmarks-with-transform.js +0 -40
- package/utils/set-in-local-storage.js +0 -3
package/RegionTags/index.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import Paper from "@mui/material/Paper";
|
|
4
|
-
import DefaultRegionLabel from "../RegionLabel";
|
|
5
|
-
import LockIcon from "@mui/icons-material/Lock";
|
|
6
|
-
|
|
7
|
-
var copyWithout = function copyWithout(obj) {
|
|
8
|
-
var newObj = _objectSpread({}, obj);
|
|
9
|
-
|
|
10
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
11
|
-
args[_key - 1] = arguments[_key];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
for (var _i = 0, _args = args; _i < _args.length; _i++) {
|
|
15
|
-
var arg = _args[_i];
|
|
16
|
-
delete newObj[arg];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return newObj;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export var RegionTags = function RegionTags(_ref) {
|
|
23
|
-
var regions = _ref.regions,
|
|
24
|
-
projectRegionBox = _ref.projectRegionBox,
|
|
25
|
-
mouseEvents = _ref.mouseEvents,
|
|
26
|
-
regionClsList = _ref.regionClsList,
|
|
27
|
-
regionTagList = _ref.regionTagList,
|
|
28
|
-
onBeginRegionEdit = _ref.onBeginRegionEdit,
|
|
29
|
-
onChangeRegion = _ref.onChangeRegion,
|
|
30
|
-
onCloseRegionEdit = _ref.onCloseRegionEdit,
|
|
31
|
-
onDeleteRegion = _ref.onDeleteRegion,
|
|
32
|
-
layoutParams = _ref.layoutParams,
|
|
33
|
-
imageSrc = _ref.imageSrc,
|
|
34
|
-
RegionEditLabel = _ref.RegionEditLabel,
|
|
35
|
-
onRegionClassAdded = _ref.onRegionClassAdded,
|
|
36
|
-
allowComments = _ref.allowComments;
|
|
37
|
-
var RegionLabel = RegionEditLabel != null ? RegionEditLabel : DefaultRegionLabel;
|
|
38
|
-
return regions.filter(function (r) {
|
|
39
|
-
return r.visible || r.visible === undefined;
|
|
40
|
-
}).map(function (region) {
|
|
41
|
-
var pbox = projectRegionBox(region);
|
|
42
|
-
var _layoutParams$current = layoutParams.current,
|
|
43
|
-
iw = _layoutParams$current.iw,
|
|
44
|
-
ih = _layoutParams$current.ih;
|
|
45
|
-
var margin = 8;
|
|
46
|
-
if (region.highlighted && region.type === "box") margin += 6;
|
|
47
|
-
var labelBoxHeight = region.editingLabels && !region.locked ? 170 : region.tags ? 60 : 50;
|
|
48
|
-
var displayOnTop = pbox.y > labelBoxHeight;
|
|
49
|
-
var coords = displayOnTop ? {
|
|
50
|
-
left: pbox.x,
|
|
51
|
-
top: pbox.y - margin / 2
|
|
52
|
-
} : {
|
|
53
|
-
left: pbox.x,
|
|
54
|
-
top: pbox.y + pbox.h + margin / 2
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
if (region.locked) {
|
|
58
|
-
return React.createElement("div", {
|
|
59
|
-
key: region.id,
|
|
60
|
-
style: _objectSpread({
|
|
61
|
-
position: "absolute"
|
|
62
|
-
}, coords, {
|
|
63
|
-
zIndex: 10 + (region.editingLabels ? 5 : 0)
|
|
64
|
-
})
|
|
65
|
-
}, React.createElement(Paper, {
|
|
66
|
-
style: _objectSpread({
|
|
67
|
-
position: "absolute",
|
|
68
|
-
left: 0
|
|
69
|
-
}, displayOnTop ? {
|
|
70
|
-
bottom: 0
|
|
71
|
-
} : {
|
|
72
|
-
top: 0
|
|
73
|
-
}, {
|
|
74
|
-
zIndex: 10,
|
|
75
|
-
backgroundColor: "#fff",
|
|
76
|
-
borderRadius: 4,
|
|
77
|
-
padding: 2,
|
|
78
|
-
paddingBottom: 0,
|
|
79
|
-
opacity: 0.5,
|
|
80
|
-
pointerEvents: "none"
|
|
81
|
-
})
|
|
82
|
-
}, React.createElement(LockIcon, {
|
|
83
|
-
style: {
|
|
84
|
-
width: 16,
|
|
85
|
-
height: 16,
|
|
86
|
-
color: "#333"
|
|
87
|
-
}
|
|
88
|
-
})));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return React.createElement("div", {
|
|
92
|
-
key: region.id,
|
|
93
|
-
style: _objectSpread({
|
|
94
|
-
position: "absolute"
|
|
95
|
-
}, coords, {
|
|
96
|
-
zIndex: 10 + (region.editingLabels ? 5 : 0),
|
|
97
|
-
width: 200
|
|
98
|
-
}),
|
|
99
|
-
onMouseDown: function onMouseDown(e) {
|
|
100
|
-
return e.preventDefault();
|
|
101
|
-
},
|
|
102
|
-
onMouseUp: function onMouseUp(e) {
|
|
103
|
-
return e.preventDefault();
|
|
104
|
-
},
|
|
105
|
-
onMouseEnter: function onMouseEnter(e) {
|
|
106
|
-
if (region.editingLabels) {
|
|
107
|
-
mouseEvents.onMouseUp(e);
|
|
108
|
-
e.button = 1;
|
|
109
|
-
mouseEvents.onMouseUp(e);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}, React.createElement("div", Object.assign({
|
|
113
|
-
style: _objectSpread({
|
|
114
|
-
position: "absolute",
|
|
115
|
-
zIndex: 20,
|
|
116
|
-
left: 0
|
|
117
|
-
}, displayOnTop ? {
|
|
118
|
-
bottom: 0
|
|
119
|
-
} : {
|
|
120
|
-
top: 0
|
|
121
|
-
})
|
|
122
|
-
}, !region.editingLabels ? copyWithout(mouseEvents, "onMouseDown", "onMouseUp") : {}), React.createElement(RegionLabel, {
|
|
123
|
-
allowedClasses: regionClsList,
|
|
124
|
-
allowedTags: regionTagList,
|
|
125
|
-
onOpen: onBeginRegionEdit,
|
|
126
|
-
onChange: onChangeRegion,
|
|
127
|
-
onClose: onCloseRegionEdit,
|
|
128
|
-
onDelete: onDeleteRegion,
|
|
129
|
-
editing: region.editingLabels,
|
|
130
|
-
region: region,
|
|
131
|
-
regions: regions,
|
|
132
|
-
imageSrc: imageSrc,
|
|
133
|
-
onRegionClassAdded: onRegionClassAdded,
|
|
134
|
-
allowComments: allowComments
|
|
135
|
-
})));
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
export default RegionTags;
|
package/SettingsDialog/index.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Dialog from "@mui/material/Dialog";
|
|
3
|
-
import DialogTitle from "@mui/material/DialogTitle";
|
|
4
|
-
import DialogContent from "@mui/material/DialogContent";
|
|
5
|
-
import DialogActions from "@mui/material/DialogActions";
|
|
6
|
-
import Button from "@mui/material/Button";
|
|
7
|
-
import Survey from "material-survey/components/Survey";
|
|
8
|
-
import { useSettings } from "../SettingsProvider";
|
|
9
|
-
export var SettingsDialog = function SettingsDialog(_ref) {
|
|
10
|
-
var open = _ref.open,
|
|
11
|
-
onClose = _ref.onClose;
|
|
12
|
-
var settings = useSettings();
|
|
13
|
-
return React.createElement(Dialog, {
|
|
14
|
-
open: open || false,
|
|
15
|
-
onClose: onClose
|
|
16
|
-
}, React.createElement(DialogTitle, null, "Settings"), React.createElement(DialogContent, {
|
|
17
|
-
style: {
|
|
18
|
-
minWidth: 400
|
|
19
|
-
}
|
|
20
|
-
}, React.createElement(Survey, {
|
|
21
|
-
variant: "flat",
|
|
22
|
-
noActions: true,
|
|
23
|
-
defaultAnswers: settings,
|
|
24
|
-
onQuestionChange: function onQuestionChange(q, a, answers) {
|
|
25
|
-
return settings.changeSetting(q, a);
|
|
26
|
-
},
|
|
27
|
-
form: {
|
|
28
|
-
questions: [{
|
|
29
|
-
type: "boolean",
|
|
30
|
-
title: "Show Crosshairs",
|
|
31
|
-
name: "showCrosshairs"
|
|
32
|
-
}, {
|
|
33
|
-
type: "boolean",
|
|
34
|
-
title: "Show Highlight Box",
|
|
35
|
-
name: "showHighlightBox"
|
|
36
|
-
}, {
|
|
37
|
-
type: "boolean",
|
|
38
|
-
title: "WASD Mode",
|
|
39
|
-
name: "wasdMode"
|
|
40
|
-
}, {
|
|
41
|
-
type: "dropdown",
|
|
42
|
-
title: "Video Playback Speed",
|
|
43
|
-
name: "videoPlaybackSpeed",
|
|
44
|
-
defaultValue: "1x",
|
|
45
|
-
choices: ["0.25x", "0.5x", "1x", "2x"]
|
|
46
|
-
}]
|
|
47
|
-
}
|
|
48
|
-
})), React.createElement(DialogActions, null, React.createElement(Button, {
|
|
49
|
-
onClick: onClose
|
|
50
|
-
}, "Close")));
|
|
51
|
-
};
|
|
52
|
-
export default SettingsDialog;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
import React, { createContext, useContext, useState } from "react";
|
|
5
|
-
var defaultSettings = {
|
|
6
|
-
showCrosshairs: false,
|
|
7
|
-
showHighlightBox: true,
|
|
8
|
-
wasdMode: true
|
|
9
|
-
};
|
|
10
|
-
export var SettingsContext = createContext(defaultSettings);
|
|
11
|
-
|
|
12
|
-
var pullSettingsFromLocalStorage = function pullSettingsFromLocalStorage() {
|
|
13
|
-
if (!window || !window.localStorage) return {};
|
|
14
|
-
var settings = {};
|
|
15
|
-
|
|
16
|
-
for (var i = 0; i < window.localStorage.length; i++) {
|
|
17
|
-
var key = window.localStorage.key(i);
|
|
18
|
-
|
|
19
|
-
if (key.startsWith("settings_")) {
|
|
20
|
-
try {
|
|
21
|
-
settings[key.replace("settings_", "")] = JSON.parse(window.localStorage.getItem(key));
|
|
22
|
-
} catch (e) {}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return settings;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export var useSettings = function useSettings() {
|
|
30
|
-
return useContext(SettingsContext);
|
|
31
|
-
};
|
|
32
|
-
export var SettingsProvider = function SettingsProvider(_ref) {
|
|
33
|
-
var children = _ref.children;
|
|
34
|
-
|
|
35
|
-
var _useState = useState(function () {
|
|
36
|
-
return pullSettingsFromLocalStorage();
|
|
37
|
-
}),
|
|
38
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
39
|
-
state = _useState2[0],
|
|
40
|
-
changeState = _useState2[1];
|
|
41
|
-
|
|
42
|
-
var changeSetting = function changeSetting(setting, value) {
|
|
43
|
-
changeState(_objectSpread({}, state, _defineProperty({}, setting, value)));
|
|
44
|
-
window.localStorage.setItem("settings_".concat(setting), JSON.stringify(value));
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return React.createElement(SettingsContext.Provider, {
|
|
48
|
-
value: _objectSpread({}, state, {
|
|
49
|
-
changeSetting: changeSetting
|
|
50
|
-
})
|
|
51
|
-
}, children);
|
|
52
|
-
};
|
|
53
|
-
export default SettingsProvider;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import TextField from "@mui/material/TextField";
|
|
3
|
-
import { makeStyles } from "@mui/styles";
|
|
4
|
-
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
5
|
-
var theme = createTheme();
|
|
6
|
-
var useStyles = makeStyles(function (theme) {
|
|
7
|
-
return {
|
|
8
|
-
shortcutKeyFieldWrapper: {
|
|
9
|
-
paddingTop: 8,
|
|
10
|
-
display: "inline-flex",
|
|
11
|
-
width: "100%"
|
|
12
|
-
},
|
|
13
|
-
shortcutKeyText: {
|
|
14
|
-
lineHeight: 0
|
|
15
|
-
},
|
|
16
|
-
shortcutTextfield: {
|
|
17
|
-
width: "100%",
|
|
18
|
-
boxSizing: "border-box",
|
|
19
|
-
textAlign: "center"
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
var ShortcutField = function ShortcutField(_ref) {
|
|
25
|
-
var actionId = _ref.actionId,
|
|
26
|
-
actionName = _ref.actionName,
|
|
27
|
-
keyName = _ref.keyName,
|
|
28
|
-
onChangeShortcut = _ref.onChangeShortcut;
|
|
29
|
-
var classes = useStyles();
|
|
30
|
-
return React.createElement(ThemeProvider, {
|
|
31
|
-
theme: theme
|
|
32
|
-
}, React.createElement("div", {
|
|
33
|
-
className: classes.shortcutKeyFieldWrapper
|
|
34
|
-
}, React.createElement(TextField, {
|
|
35
|
-
variant: "outlined",
|
|
36
|
-
label: actionName,
|
|
37
|
-
className: classes.shortcutTextfield,
|
|
38
|
-
value: keyName,
|
|
39
|
-
onKeyPress: function onKeyPress(e) {
|
|
40
|
-
onChangeShortcut(actionId, e.key);
|
|
41
|
-
e.stopPropagation();
|
|
42
|
-
}
|
|
43
|
-
})));
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default ShortcutField;
|
package/Shortcuts/index.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import React, { useState, useEffect } from "react";
|
|
4
|
-
import SidebarBoxContainer from "../SidebarBoxContainer";
|
|
5
|
-
import { setIn } from "seamless-immutable";
|
|
6
|
-
import ShortcutField from "./ShortcutField";
|
|
7
|
-
var defaultShortcuts = {
|
|
8
|
-
select: {
|
|
9
|
-
action: {
|
|
10
|
-
type: "SELECT_TOOL"
|
|
11
|
-
},
|
|
12
|
-
name: "Select Region",
|
|
13
|
-
key: "Escape"
|
|
14
|
-
},
|
|
15
|
-
zoom: {
|
|
16
|
-
action: {
|
|
17
|
-
type: "SELECT_TOOL"
|
|
18
|
-
},
|
|
19
|
-
name: "Zoom In/Out",
|
|
20
|
-
key: "z"
|
|
21
|
-
},
|
|
22
|
-
"create-point": {
|
|
23
|
-
action: {
|
|
24
|
-
type: "SELECT_TOOL"
|
|
25
|
-
},
|
|
26
|
-
name: "Create Point"
|
|
27
|
-
},
|
|
28
|
-
"create-box": {
|
|
29
|
-
action: {
|
|
30
|
-
type: "SELECT_TOOL"
|
|
31
|
-
},
|
|
32
|
-
name: "Add Bounding Box",
|
|
33
|
-
key: "b"
|
|
34
|
-
},
|
|
35
|
-
pan: {
|
|
36
|
-
action: {
|
|
37
|
-
type: "SELECT_TOOL"
|
|
38
|
-
},
|
|
39
|
-
name: "Pan"
|
|
40
|
-
},
|
|
41
|
-
"create-polygon": {
|
|
42
|
-
action: {
|
|
43
|
-
type: "SELECT_TOOL"
|
|
44
|
-
},
|
|
45
|
-
name: "Create Polygon"
|
|
46
|
-
},
|
|
47
|
-
"create-pixel": {
|
|
48
|
-
action: {
|
|
49
|
-
type: "SELECT_TOOL"
|
|
50
|
-
},
|
|
51
|
-
name: "Create Pixel"
|
|
52
|
-
},
|
|
53
|
-
"prev-image": {
|
|
54
|
-
action: {
|
|
55
|
-
type: "HEADER_BUTTON_CLICKED",
|
|
56
|
-
buttonName: "Prev"
|
|
57
|
-
},
|
|
58
|
-
name: "Previous Image",
|
|
59
|
-
key: "a"
|
|
60
|
-
},
|
|
61
|
-
"next-image": {
|
|
62
|
-
action: {
|
|
63
|
-
type: "HEADER_BUTTON_CLICKED",
|
|
64
|
-
buttonName: "Next"
|
|
65
|
-
},
|
|
66
|
-
name: "Next Image",
|
|
67
|
-
key: "d" //"ArrowRight"
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
export default (function (_ref) {
|
|
72
|
-
var onShortcutActionDispatched = _ref.onShortcutActionDispatched;
|
|
73
|
-
|
|
74
|
-
var _useState = useState({}),
|
|
75
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
76
|
-
shortcuts = _useState2[0],
|
|
77
|
-
setShortcuts = _useState2[1]; // useLocalStorage
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
useEffect(function () {
|
|
81
|
-
var newShortcuts = _objectSpread({}, shortcuts);
|
|
82
|
-
|
|
83
|
-
for (var _i = 0, _Object$keys = Object.keys(defaultShortcuts); _i < _Object$keys.length; _i++) {
|
|
84
|
-
var actionId = _Object$keys[_i];
|
|
85
|
-
|
|
86
|
-
if (!newShortcuts[actionId]) {
|
|
87
|
-
newShortcuts[actionId] = defaultShortcuts[actionId];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
setShortcuts(newShortcuts);
|
|
92
|
-
}, []);
|
|
93
|
-
|
|
94
|
-
var onChangeShortcut = function onChangeShortcut(actionId, keyName) {
|
|
95
|
-
setShortcuts(setIn(shortcuts, [actionId, "key"], keyName));
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
useEffect(function () {
|
|
99
|
-
var handleKeyPress = function handleKeyPress(e) {
|
|
100
|
-
for (var actionId in shortcuts) {
|
|
101
|
-
var shortcut = shortcuts[actionId];
|
|
102
|
-
|
|
103
|
-
if (!shortcut || !shortcut.key) {
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (e.key === shortcut.key) {
|
|
108
|
-
onShortcutActionDispatched(_objectSpread({}, shortcut.action, {
|
|
109
|
-
selectedTool: actionId
|
|
110
|
-
}));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
window.addEventListener("keypress", handleKeyPress);
|
|
116
|
-
return function () {
|
|
117
|
-
window.removeEventListener("keypress", handleKeyPress);
|
|
118
|
-
document.activeElement.blur();
|
|
119
|
-
};
|
|
120
|
-
}, [shortcuts]);
|
|
121
|
-
return React.createElement(SidebarBoxContainer, {
|
|
122
|
-
title: "Shortcuts"
|
|
123
|
-
}, Object.keys(shortcuts).map(function (actionId, index) {
|
|
124
|
-
if (!shortcuts[actionId]) return null;
|
|
125
|
-
return React.createElement(ShortcutField, {
|
|
126
|
-
key: actionId,
|
|
127
|
-
actionId: actionId,
|
|
128
|
-
actionName: shortcuts[actionId].name,
|
|
129
|
-
keyName: shortcuts[actionId].key || "",
|
|
130
|
-
onChangeShortcut: onChangeShortcut
|
|
131
|
-
});
|
|
132
|
-
}).filter(Boolean));
|
|
133
|
-
});
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from "react";
|
|
2
|
-
import { HotKeys } from "react-hotkeys";
|
|
3
|
-
export var defaultHotkeys = [{
|
|
4
|
-
id: "select_tool",
|
|
5
|
-
description: "Switch to the Select Tool",
|
|
6
|
-
binding: "escape"
|
|
7
|
-
}, {
|
|
8
|
-
id: "zoom_tool",
|
|
9
|
-
description: "Select the Zoom Tool",
|
|
10
|
-
binding: "z"
|
|
11
|
-
}, {
|
|
12
|
-
id: "create_point",
|
|
13
|
-
description: "Create a point"
|
|
14
|
-
}, {
|
|
15
|
-
id: "create_bounding_box",
|
|
16
|
-
description: "Create a bounding box",
|
|
17
|
-
binding: "b"
|
|
18
|
-
}, {
|
|
19
|
-
id: "pan_tool",
|
|
20
|
-
description: "Select the Pan Tool",
|
|
21
|
-
binding: "m"
|
|
22
|
-
}, {
|
|
23
|
-
id: "create_polygon",
|
|
24
|
-
description: "Create a Polygon",
|
|
25
|
-
binding: "p"
|
|
26
|
-
}, {
|
|
27
|
-
id: "create_pixel",
|
|
28
|
-
description: "Create a Pixel Mask"
|
|
29
|
-
}, {
|
|
30
|
-
id: "save_and_previous_sample",
|
|
31
|
-
description: "Save and go to previous sample",
|
|
32
|
-
binding: "ArrowLeft"
|
|
33
|
-
}, {
|
|
34
|
-
id: "save_and_next_sample",
|
|
35
|
-
description: "Save and go to next sample",
|
|
36
|
-
binding: "ArrowRight"
|
|
37
|
-
}, {
|
|
38
|
-
id: "save_and_exit_sample",
|
|
39
|
-
description: "Save and exit current sample"
|
|
40
|
-
}, {
|
|
41
|
-
id: "exit_sample",
|
|
42
|
-
description: "Exit sample without saving"
|
|
43
|
-
}, {
|
|
44
|
-
id: "delete_region",
|
|
45
|
-
description: "Delete selected region",
|
|
46
|
-
binding: "d"
|
|
47
|
-
}, {
|
|
48
|
-
id: "undo",
|
|
49
|
-
description: "Undo latest change",
|
|
50
|
-
binding: "Ctrl+z"
|
|
51
|
-
}];
|
|
52
|
-
export var defaultKeyMap = {};
|
|
53
|
-
|
|
54
|
-
for (var _i = 0, _defaultHotkeys = defaultHotkeys; _i < _defaultHotkeys.length; _i++) {
|
|
55
|
-
var _ref4 = _defaultHotkeys[_i];
|
|
56
|
-
var id = _ref4.id;
|
|
57
|
-
var binding = _ref4.binding;
|
|
58
|
-
defaultKeyMap[id] = binding;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export var useDispatchHotkeyHandlers = function useDispatchHotkeyHandlers(_ref2) {
|
|
62
|
-
var dispatch = _ref2.dispatch;
|
|
63
|
-
var handlers = useMemo(function () {
|
|
64
|
-
return {
|
|
65
|
-
select_tool: function select_tool() {
|
|
66
|
-
dispatch({
|
|
67
|
-
type: "SELECT_TOOL",
|
|
68
|
-
selectedTool: "select"
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
zoom_tool: function zoom_tool() {
|
|
72
|
-
dispatch({
|
|
73
|
-
type: "SELECT_TOOL",
|
|
74
|
-
selectedTool: "zoom"
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
create_point: function create_point() {
|
|
78
|
-
dispatch({
|
|
79
|
-
type: "SELECT_TOOL",
|
|
80
|
-
selectedTool: "create-point"
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
create_bounding_box: function create_bounding_box() {
|
|
84
|
-
dispatch({
|
|
85
|
-
type: "SELECT_TOOL",
|
|
86
|
-
selectedTool: "create-box"
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
pan_tool: function pan_tool() {
|
|
90
|
-
dispatch({
|
|
91
|
-
type: "SELECT_TOOL",
|
|
92
|
-
selectedTool: "pan"
|
|
93
|
-
});
|
|
94
|
-
},
|
|
95
|
-
create_polygon: function create_polygon() {
|
|
96
|
-
dispatch({
|
|
97
|
-
type: "SELECT_TOOL",
|
|
98
|
-
selectedTool: "create-polygon"
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
create_pixel: function create_pixel() {
|
|
102
|
-
dispatch({
|
|
103
|
-
type: "SELECT_TOOL",
|
|
104
|
-
selectedTool: "create-pixel"
|
|
105
|
-
});
|
|
106
|
-
},
|
|
107
|
-
save_and_previous_sample: function save_and_previous_sample() {
|
|
108
|
-
dispatch({
|
|
109
|
-
type: "HEADER_BUTTON_CLICKED",
|
|
110
|
-
buttonName: "Prev"
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
save_and_next_sample: function save_and_next_sample() {
|
|
114
|
-
dispatch({
|
|
115
|
-
type: "HEADER_BUTTON_CLICKED",
|
|
116
|
-
buttonName: "Next"
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
save_and_exit_sample: function save_and_exit_sample() {
|
|
120
|
-
dispatch({
|
|
121
|
-
type: "HEADER_BUTTON_CLICKED",
|
|
122
|
-
buttonName: "Save"
|
|
123
|
-
});
|
|
124
|
-
},
|
|
125
|
-
delete_region: function delete_region() {
|
|
126
|
-
dispatch({
|
|
127
|
-
type: "DELETE_SELECTED_REGION"
|
|
128
|
-
});
|
|
129
|
-
},
|
|
130
|
-
undo: function undo() {
|
|
131
|
-
dispatch({
|
|
132
|
-
type: "RESTORE_HISTORY"
|
|
133
|
-
});
|
|
134
|
-
} // TODO
|
|
135
|
-
// exit_sample: () => {
|
|
136
|
-
// dispatch({
|
|
137
|
-
// type: "",
|
|
138
|
-
// })
|
|
139
|
-
// }
|
|
140
|
-
|
|
141
|
-
};
|
|
142
|
-
}, [dispatch]);
|
|
143
|
-
return handlers;
|
|
144
|
-
};
|
|
145
|
-
export default (function (_ref3) {
|
|
146
|
-
var children = _ref3.children,
|
|
147
|
-
dispatch = _ref3.dispatch;
|
|
148
|
-
var handlers = useDispatchHotkeyHandlers({
|
|
149
|
-
dispatch: dispatch
|
|
150
|
-
});
|
|
151
|
-
return React.createElement(HotKeys, {
|
|
152
|
-
allowChanges: true,
|
|
153
|
-
handlers: handlers
|
|
154
|
-
}, children);
|
|
155
|
-
});
|
package/Sidebar/index.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { styled } from "@mui/styles";
|
|
3
|
-
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
4
|
-
import TaskDescription from "../TaskDescriptionSidebarBox";
|
|
5
|
-
import ImageSelector from "../ImageSelectorSidebarBox";
|
|
6
|
-
import RegionSelector from "../RegionSelectorSidebarBox";
|
|
7
|
-
import History from "../HistorySidebarBox";
|
|
8
|
-
import DebugBox from "../DebugSidebarBox";
|
|
9
|
-
import TagsSidebarBox from "../TagsSidebarBox";
|
|
10
|
-
import KeyframesSelector from "../KeyframesSelectorSidebarBox";
|
|
11
|
-
var theme = createTheme();
|
|
12
|
-
var Container = styled("div")(function (_ref) {
|
|
13
|
-
var theme = _ref.theme;
|
|
14
|
-
return {};
|
|
15
|
-
});
|
|
16
|
-
var emptyArr = [];
|
|
17
|
-
export var Sidebar = function Sidebar(_ref2) {
|
|
18
|
-
var debug = _ref2.debug,
|
|
19
|
-
taskDescription = _ref2.taskDescription,
|
|
20
|
-
keyframes = _ref2.keyframes,
|
|
21
|
-
images = _ref2.images,
|
|
22
|
-
regions = _ref2.regions,
|
|
23
|
-
history = _ref2.history,
|
|
24
|
-
labelImages = _ref2.labelImages,
|
|
25
|
-
currentImage = _ref2.currentImage,
|
|
26
|
-
currentVideoTime = _ref2.currentVideoTime,
|
|
27
|
-
imageClsList = _ref2.imageClsList,
|
|
28
|
-
imageTagList = _ref2.imageTagList,
|
|
29
|
-
onChangeImage = _ref2.onChangeImage,
|
|
30
|
-
onSelectRegion = _ref2.onSelectRegion,
|
|
31
|
-
onSelectImage = _ref2.onSelectImage,
|
|
32
|
-
onChangeRegion = _ref2.onChangeRegion,
|
|
33
|
-
onDeleteRegion = _ref2.onDeleteRegion,
|
|
34
|
-
_onRestoreHistory = _ref2.onRestoreHistory,
|
|
35
|
-
onChangeVideoTime = _ref2.onChangeVideoTime,
|
|
36
|
-
onDeleteKeyframe = _ref2.onDeleteKeyframe,
|
|
37
|
-
onShortcutActionDispatched = _ref2.onShortcutActionDispatched;
|
|
38
|
-
if (!regions) regions = emptyArr;
|
|
39
|
-
return React.createElement(ThemeProvider, {
|
|
40
|
-
theme: theme
|
|
41
|
-
}, React.createElement(Container, null, debug && React.createElement(DebugBox, {
|
|
42
|
-
state: debug,
|
|
43
|
-
lastAction: debug.lastAction
|
|
44
|
-
}), taskDescription && (taskDescription || "").length > 1 && React.createElement(TaskDescription, {
|
|
45
|
-
description: taskDescription
|
|
46
|
-
}), labelImages && React.createElement(TagsSidebarBox, {
|
|
47
|
-
currentImage: currentImage,
|
|
48
|
-
imageClsList: imageClsList,
|
|
49
|
-
imageTagList: imageTagList,
|
|
50
|
-
onChangeImage: onChangeImage,
|
|
51
|
-
expandedByDefault: true
|
|
52
|
-
}), React.createElement(RegionSelector, {
|
|
53
|
-
regions: regions,
|
|
54
|
-
onSelectRegion: onSelectRegion,
|
|
55
|
-
onChangeRegion: onChangeRegion,
|
|
56
|
-
onDeleteRegion: onDeleteRegion
|
|
57
|
-
}), keyframes && React.createElement(KeyframesSelector, {
|
|
58
|
-
currentVideoTime: currentVideoTime,
|
|
59
|
-
keyframes: keyframes,
|
|
60
|
-
onChangeVideoTime: onChangeVideoTime,
|
|
61
|
-
onDeleteKeyframe: onDeleteKeyframe
|
|
62
|
-
}), React.createElement(History, {
|
|
63
|
-
history: history,
|
|
64
|
-
onRestoreHistory: function onRestoreHistory() {
|
|
65
|
-
return _onRestoreHistory();
|
|
66
|
-
}
|
|
67
|
-
})));
|
|
68
|
-
};
|
|
69
|
-
export default Sidebar;
|