@searpent/react-image-annotate 2.0.0 → 2.0.3
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/index.js +169 -0
- package/Annotator/reducers/combine-reducers.js +14 -0
- package/Annotator/reducers/convert-expanding-line-to-polygon.js +73 -0
- package/{src/Annotator → Annotator}/reducers/fix-twisted.js +3 -5
- package/Annotator/reducers/general-reducer.js +1058 -0
- package/Annotator/reducers/get-active-image.js +27 -0
- package/Annotator/reducers/get-implied-video-regions.js +180 -0
- package/Annotator/reducers/history-handler.js +38 -0
- package/Annotator/reducers/image-reducer.js +20 -0
- package/Annotator/reducers/video-reducer.js +88 -0
- package/ClassSelectionMenu/index.js +135 -0
- package/Crosshairs/index.js +53 -0
- package/DebugSidebarBox/index.js +20 -0
- package/DemoSite/Editor.js +194 -0
- package/DemoSite/ErrorBoundaryDialog.js +64 -0
- package/DemoSite/index.js +40 -0
- package/FullImageSegmentationAnnotator/index.js +7 -0
- package/GroupSelectorSidebarBox/index.js +63 -0
- package/HighlightBox/index.js +99 -0
- package/HistorySidebarBox/index.js +71 -0
- package/ImageCanvas/index.js +424 -0
- package/ImageCanvas/region-tools.js +165 -0
- package/{src/ImageCanvas → ImageCanvas}/styles.js +12 -8
- package/ImageCanvas/use-mouse.js +180 -0
- package/ImageCanvas/use-project-box.js +27 -0
- package/ImageCanvas/use-wasd-mode.js +62 -0
- package/ImageMask/index.js +133 -0
- package/ImageMask/load-image.js +25 -0
- package/ImageSelectorSidebarBox/index.js +60 -0
- package/KeyframeTimeline/get-time-string.js +27 -0
- package/KeyframeTimeline/index.js +233 -0
- package/KeyframesSelectorSidebarBox/index.js +93 -0
- package/LandingPage/index.js +159 -0
- package/MainLayout/icon-dictionary.js +104 -0
- package/MainLayout/index.js +366 -0
- package/{src/MainLayout → MainLayout}/styles.js +6 -7
- package/MainLayout/types.js +0 -0
- package/MainLayout/use-implied-video-regions.js +13 -0
- package/PointDistances/index.js +73 -0
- package/PreventScrollToParents/index.js +51 -0
- package/RegionLabel/index.js +191 -0
- package/{src/RegionLabel → RegionLabel}/styles.js +12 -15
- package/RegionSelectAndTransformBoxes/index.js +167 -0
- package/RegionSelectorSidebarBox/index.js +248 -0
- package/{src/RegionSelectorSidebarBox → RegionSelectorSidebarBox}/styles.js +13 -14
- package/RegionShapes/index.js +274 -0
- package/RegionTags/index.js +138 -0
- package/SettingsDialog/index.js +52 -0
- package/SettingsProvider/index.js +53 -0
- package/Shortcuts/ShortcutField.js +46 -0
- package/Shortcuts/index.js +133 -0
- package/ShortcutsManager/index.js +155 -0
- package/Sidebar/index.js +69 -0
- package/SidebarBoxContainer/index.js +93 -0
- package/SmallToolButton/index.js +42 -0
- package/TagsSidebarBox/index.js +105 -0
- package/TaskDescriptionSidebarBox/index.js +58 -0
- package/Theme/index.js +30 -0
- package/VideoOrImageCanvasBackground/index.js +151 -0
- package/colors.js +14 -0
- package/hooks/use-event-callback.js +10 -0
- package/hooks/use-exclude-pattern.js +24 -0
- package/hooks/use-load-image.js +26 -0
- package/hooks/use-window-size.js +46 -0
- package/{src/hooks → hooks}/xpattern.js +1 -1
- package/index.js +3 -0
- package/lib.js +3 -0
- package/package.json +1 -1
- package/stories.js +5 -0
- package/utils/get-from-local-storage.js +7 -0
- package/utils/get-hotkey-help-text.js +9 -0
- package/utils/get-landmarks-with-transform.js +40 -0
- package/utils/set-in-local-storage.js +3 -0
- package/.babelrc +0 -6
- package/.env +0 -1
- package/.flowconfig +0 -2
- package/.github/workflows/release-on-master.yml +0 -32
- package/.github/workflows/test.yml +0 -16
- package/.prettierrc +0 -3
- package/.releaserc.js +0 -18
- package/.storybook/addons.js +0 -2
- package/.storybook/config.js +0 -16
- package/LICENSE +0 -21
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -38
- package/src/Annotator/bike-pic.png +0 -0
- package/src/Annotator/bike-pic2.png +0 -0
- package/src/Annotator/dab-keyframes.story.json +0 -1
- package/src/Annotator/index.js +0 -206
- package/src/Annotator/index.story.js +0 -727
- package/src/Annotator/poses.story.js +0 -150
- package/src/Annotator/reducers/combine-reducers.js +0 -7
- package/src/Annotator/reducers/convert-expanding-line-to-polygon.js +0 -53
- package/src/Annotator/reducers/general-reducer.js +0 -914
- package/src/Annotator/reducers/get-active-image.js +0 -21
- package/src/Annotator/reducers/get-implied-video-regions.js +0 -115
- package/src/Annotator/reducers/history-handler.js +0 -60
- package/src/Annotator/reducers/image-reducer.js +0 -23
- package/src/Annotator/reducers/video-reducer.js +0 -85
- package/src/Annotator/video.story.js +0 -51
- package/src/ClassSelectionMenu/index.js +0 -108
- package/src/Crosshairs/index.js +0 -64
- package/src/DebugSidebarBox/index.js +0 -36
- package/src/DemoSite/Editor.js +0 -235
- package/src/DemoSite/ErrorBoundaryDialog.js +0 -34
- package/src/DemoSite/index.js +0 -41
- package/src/DemoSite/index.story.js +0 -10
- package/src/DemoSite/simple-segmentation-example.json +0 -572
- 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 +0 -7
- package/src/FullImageSegmentationAnnotator/index.story.js +0 -177
- package/src/FullImageSegmentationAnnotator/orange.story.png +0 -0
- package/src/HighlightBox/index.js +0 -143
- package/src/HistorySidebarBox/index.js +0 -78
- package/src/ImageCanvas/dancing-man.story.jpg +0 -0
- package/src/ImageCanvas/index.js +0 -488
- package/src/ImageCanvas/index.story.js +0 -214
- package/src/ImageCanvas/mouse_mask.story.png +0 -0
- package/src/ImageCanvas/region-tools.js +0 -171
- package/src/ImageCanvas/seves_desk.story.jpg +0 -0
- package/src/ImageCanvas/use-mouse.js +0 -168
- package/src/ImageCanvas/use-project-box.js +0 -23
- package/src/ImageCanvas/use-wasd-mode.js +0 -50
- package/src/ImageMask/index.js +0 -127
- package/src/ImageMask/load-image.js +0 -32
- package/src/ImageSelectorSidebarBox/index.js +0 -54
- package/src/KeyframeTimeline/get-time-string.js +0 -25
- package/src/KeyframeTimeline/index.js +0 -223
- package/src/KeyframesSelectorSidebarBox/index.js +0 -93
- package/src/LandingPage/content.md +0 -57
- package/src/LandingPage/github-markdown.css +0 -964
- package/src/LandingPage/index.js +0 -147
- package/src/MainLayout/icon-dictionary.js +0 -79
- package/src/MainLayout/index.js +0 -420
- package/src/MainLayout/index.story.js +0 -240
- package/src/MainLayout/types.js +0 -156
- package/src/MainLayout/use-implied-video-regions.js +0 -17
- package/src/PointDistances/index.js +0 -90
- package/src/PreventScrollToParents/index.js +0 -48
- package/src/PreventScrollToParents/index.story.js +0 -23
- package/src/RegionLabel/index.js +0 -201
- package/src/RegionSelectAndTransformBoxes/index.js +0 -234
- package/src/RegionSelectorSidebarBox/index.js +0 -216
- package/src/RegionShapes/index.js +0 -236
- package/src/RegionTags/index.js +0 -130
- package/src/SettingsDialog/index.js +0 -58
- package/src/SettingsProvider/index.js +0 -44
- package/src/Shortcuts/ShortcutField.js +0 -44
- package/src/Shortcuts/index.js +0 -129
- package/src/ShortcutsManager/index.js +0 -162
- package/src/Sidebar/index.js +0 -117
- package/src/SidebarBoxContainer/index.js +0 -93
- package/src/SmallToolButton/index.js +0 -57
- package/src/TagsSidebarBox/index.js +0 -93
- package/src/TaskDescriptionSidebarBox/index.js +0 -43
- package/src/Theme/index.js +0 -36
- package/src/VideoOrImageCanvasBackground/index.js +0 -170
- package/src/colors.js +0 -32
- package/src/hooks/use-event-callback.js +0 -11
- package/src/hooks/use-exclude-pattern.js +0 -27
- package/src/hooks/use-load-image.js +0 -21
- package/src/hooks/use-window-size.js +0 -46
- package/src/hooks/xpattern.png +0 -0
- package/src/index.js +0 -18
- package/src/lib.js +0 -7
- package/src/screenshot.png +0 -0
- package/src/site.css +0 -5
- package/src/stories.js +0 -2
- package/src/utils/get-from-local-storage.js +0 -7
- package/src/utils/get-hotkey-help-text.js +0 -11
- package/src/utils/get-landmarks-with-transform.js +0 -23
- package/src/utils/set-in-local-storage.js +0 -6
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import { FullScreen, useFullScreenHandle } from "react-full-screen";
|
|
4
|
+
import React, { useCallback, useRef } from "react";
|
|
5
|
+
import { makeStyles } from "@mui/styles";
|
|
6
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
7
|
+
import { styled } from "@mui/material/styles";
|
|
8
|
+
import ClassSelectionMenu from "../ClassSelectionMenu";
|
|
9
|
+
import DebugBox from "../DebugSidebarBox";
|
|
10
|
+
import HistorySidebarBox from "../HistorySidebarBox";
|
|
11
|
+
import ImageCanvas from "../ImageCanvas";
|
|
12
|
+
import ImageSelector from "../ImageSelectorSidebarBox";
|
|
13
|
+
import GroupSelector from "../GroupSelectorSidebarBox";
|
|
14
|
+
import KeyframeTimeline from "../KeyframeTimeline";
|
|
15
|
+
import KeyframesSelector from "../KeyframesSelectorSidebarBox";
|
|
16
|
+
import RegionSelector from "../RegionSelectorSidebarBox";
|
|
17
|
+
import SettingsDialog from "../SettingsDialog";
|
|
18
|
+
import TagsSidebarBox from "../TagsSidebarBox";
|
|
19
|
+
import TaskDescription from "../TaskDescriptionSidebarBox";
|
|
20
|
+
import Workspace from "react-material-workspace-layout/Workspace";
|
|
21
|
+
import classnames from "classnames";
|
|
22
|
+
import getActiveImage from "../Annotator/reducers/get-active-image";
|
|
23
|
+
import getHotkeyHelpText from "../utils/get-hotkey-help-text";
|
|
24
|
+
import iconDictionary from "./icon-dictionary";
|
|
25
|
+
import styles from "./styles";
|
|
26
|
+
import { useDispatchHotkeyHandlers } from "../ShortcutsManager";
|
|
27
|
+
import useEventCallback from "use-event-callback";
|
|
28
|
+
import useImpliedVideoRegions from "./use-implied-video-regions";
|
|
29
|
+
import useKey from "use-key-hook";
|
|
30
|
+
import { useSettings } from "../SettingsProvider";
|
|
31
|
+
import { withHotKeys } from "react-hotkeys"; // import Fullscreen from "../Fullscreen"
|
|
32
|
+
|
|
33
|
+
var emptyArr = [];
|
|
34
|
+
var theme = createTheme();
|
|
35
|
+
var useStyles = makeStyles(function (theme) {
|
|
36
|
+
return styles;
|
|
37
|
+
});
|
|
38
|
+
var HotkeyDiv = withHotKeys(function (_ref) {
|
|
39
|
+
var hotKeys = _ref.hotKeys,
|
|
40
|
+
children = _ref.children,
|
|
41
|
+
divRef = _ref.divRef,
|
|
42
|
+
props = _objectWithoutProperties(_ref, ["hotKeys", "children", "divRef"]);
|
|
43
|
+
|
|
44
|
+
return React.createElement("div", Object.assign({}, _objectSpread({}, hotKeys, props), {
|
|
45
|
+
ref: divRef
|
|
46
|
+
}), children);
|
|
47
|
+
});
|
|
48
|
+
var FullScreenContainer = styled("div")(function (_ref2) {
|
|
49
|
+
var theme = _ref2.theme;
|
|
50
|
+
return {
|
|
51
|
+
width: "100%",
|
|
52
|
+
height: "100%",
|
|
53
|
+
"& .fullscreen": {
|
|
54
|
+
width: "100%",
|
|
55
|
+
height: "100%"
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
export var MainLayout = function MainLayout(_ref3) {
|
|
60
|
+
var state = _ref3.state,
|
|
61
|
+
dispatch = _ref3.dispatch,
|
|
62
|
+
_ref3$alwaysShowNextB = _ref3.alwaysShowNextButton,
|
|
63
|
+
alwaysShowNextButton = _ref3$alwaysShowNextB === void 0 ? false : _ref3$alwaysShowNextB,
|
|
64
|
+
_ref3$alwaysShowPrevB = _ref3.alwaysShowPrevButton,
|
|
65
|
+
alwaysShowPrevButton = _ref3$alwaysShowPrevB === void 0 ? false : _ref3$alwaysShowPrevB,
|
|
66
|
+
RegionEditLabel = _ref3.RegionEditLabel,
|
|
67
|
+
onRegionClassAdded = _ref3.onRegionClassAdded,
|
|
68
|
+
hideHeader = _ref3.hideHeader,
|
|
69
|
+
hideHeaderText = _ref3.hideHeaderText,
|
|
70
|
+
_ref3$hideNext = _ref3.hideNext,
|
|
71
|
+
hideNext = _ref3$hideNext === void 0 ? false : _ref3$hideNext,
|
|
72
|
+
_ref3$hidePrev = _ref3.hidePrev,
|
|
73
|
+
hidePrev = _ref3$hidePrev === void 0 ? false : _ref3$hidePrev,
|
|
74
|
+
_ref3$hideClone = _ref3.hideClone,
|
|
75
|
+
hideClone = _ref3$hideClone === void 0 ? false : _ref3$hideClone,
|
|
76
|
+
_ref3$hideSettings = _ref3.hideSettings,
|
|
77
|
+
hideSettings = _ref3$hideSettings === void 0 ? false : _ref3$hideSettings,
|
|
78
|
+
_ref3$hideFullScreen = _ref3.hideFullScreen,
|
|
79
|
+
hideFullScreen = _ref3$hideFullScreen === void 0 ? false : _ref3$hideFullScreen,
|
|
80
|
+
_ref3$hideSave = _ref3.hideSave,
|
|
81
|
+
hideSave = _ref3$hideSave === void 0 ? false : _ref3$hideSave,
|
|
82
|
+
_ref3$groups = _ref3.groups,
|
|
83
|
+
groups = _ref3$groups === void 0 ? [] : _ref3$groups,
|
|
84
|
+
_ref3$onGroupSelect = _ref3.onGroupSelect,
|
|
85
|
+
onGroupSelect = _ref3$onGroupSelect === void 0 ? function () {} : _ref3$onGroupSelect,
|
|
86
|
+
_ref3$selectedGroupId = _ref3.selectedGroupId,
|
|
87
|
+
selectedGroupId = _ref3$selectedGroupId === void 0 ? null : _ref3$selectedGroupId,
|
|
88
|
+
_ref3$hideHistory = _ref3.hideHistory,
|
|
89
|
+
hideHistory = _ref3$hideHistory === void 0 ? false : _ref3$hideHistory;
|
|
90
|
+
var classes = useStyles();
|
|
91
|
+
var settings = useSettings();
|
|
92
|
+
var fullScreenHandle = useFullScreenHandle();
|
|
93
|
+
var memoizedActionFns = useRef({});
|
|
94
|
+
|
|
95
|
+
var action = function action(type) {
|
|
96
|
+
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
97
|
+
params[_key - 1] = arguments[_key];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var fnKey = "".concat(type, "(").concat(params.join(","), ")");
|
|
101
|
+
if (memoizedActionFns.current[fnKey]) return memoizedActionFns.current[fnKey];
|
|
102
|
+
|
|
103
|
+
var fn = function fn() {
|
|
104
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
105
|
+
args[_key2] = arguments[_key2];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return params.length > 0 ? dispatch(_objectSpread({
|
|
109
|
+
type: type
|
|
110
|
+
}, params.reduce(function (acc, p, i) {
|
|
111
|
+
return acc[p] = args[i], acc;
|
|
112
|
+
}, {}))) : dispatch(_objectSpread({
|
|
113
|
+
type: type
|
|
114
|
+
}, args[0]));
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
memoizedActionFns.current[fnKey] = fn;
|
|
118
|
+
return fn;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
var _getActiveImage = getActiveImage(state),
|
|
122
|
+
currentImageIndex = _getActiveImage.currentImageIndex,
|
|
123
|
+
activeImage = _getActiveImage.activeImage;
|
|
124
|
+
|
|
125
|
+
var nextImage;
|
|
126
|
+
|
|
127
|
+
if (currentImageIndex !== null) {
|
|
128
|
+
nextImage = state.images[currentImageIndex + 1];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
useKey(function () {
|
|
132
|
+
return dispatch({
|
|
133
|
+
type: "CANCEL"
|
|
134
|
+
});
|
|
135
|
+
}, {
|
|
136
|
+
detectKeys: [27]
|
|
137
|
+
});
|
|
138
|
+
var isAVideoFrame = activeImage && activeImage.frameTime !== undefined;
|
|
139
|
+
var innerContainerRef = useRef();
|
|
140
|
+
var hotkeyHandlers = useDispatchHotkeyHandlers({
|
|
141
|
+
dispatch: dispatch
|
|
142
|
+
});
|
|
143
|
+
var impliedVideoRegions = useImpliedVideoRegions(state);
|
|
144
|
+
var refocusOnMouseEvent = useCallback(function (e) {
|
|
145
|
+
if (!innerContainerRef.current) return;
|
|
146
|
+
if (innerContainerRef.current.contains(document.activeElement)) return;
|
|
147
|
+
|
|
148
|
+
if (innerContainerRef.current.contains(e.target)) {
|
|
149
|
+
innerContainerRef.current.focus();
|
|
150
|
+
e.target.focus();
|
|
151
|
+
}
|
|
152
|
+
}, []);
|
|
153
|
+
var canvas = React.createElement(ImageCanvas, Object.assign({}, settings, {
|
|
154
|
+
showCrosshairs: settings.showCrosshairs && !["select", "pan", "zoom"].includes(state.selectedTool),
|
|
155
|
+
key: state.selectedImage,
|
|
156
|
+
showMask: state.showMask,
|
|
157
|
+
fullImageSegmentationMode: state.fullImageSegmentationMode,
|
|
158
|
+
autoSegmentationOptions: state.autoSegmentationOptions,
|
|
159
|
+
showTags: state.showTags,
|
|
160
|
+
allowedArea: state.allowedArea,
|
|
161
|
+
modifyingAllowedArea: state.selectedTool === "modify-allowed-area",
|
|
162
|
+
regionClsList: state.regionClsList,
|
|
163
|
+
regionTagList: state.regionTagList,
|
|
164
|
+
regions: state.annotationType === "image" ? activeImage.regions || [] : impliedVideoRegions,
|
|
165
|
+
realSize: activeImage ? activeImage.realSize : undefined,
|
|
166
|
+
videoPlaying: state.videoPlaying,
|
|
167
|
+
imageSrc: state.annotationType === "image" ? activeImage.src : null,
|
|
168
|
+
videoSrc: state.annotationType === "video" ? state.videoSrc : null,
|
|
169
|
+
pointDistancePrecision: state.pointDistancePrecision,
|
|
170
|
+
createWithPrimary: state.selectedTool.includes("create"),
|
|
171
|
+
dragWithPrimary: state.selectedTool === "pan",
|
|
172
|
+
zoomWithPrimary: state.selectedTool === "zoom",
|
|
173
|
+
showPointDistances: state.showPointDistances,
|
|
174
|
+
videoTime: state.annotationType === "image" ? state.selectedImageFrameTime : state.currentVideoTime,
|
|
175
|
+
keypointDefinitions: state.keypointDefinitions,
|
|
176
|
+
onMouseMove: action("MOUSE_MOVE"),
|
|
177
|
+
onMouseDown: action("MOUSE_DOWN"),
|
|
178
|
+
onMouseUp: action("MOUSE_UP"),
|
|
179
|
+
onChangeRegion: action("CHANGE_REGION", "region"),
|
|
180
|
+
onBeginRegionEdit: action("OPEN_REGION_EDITOR", "region"),
|
|
181
|
+
onCloseRegionEdit: action("CLOSE_REGION_EDITOR", "region"),
|
|
182
|
+
onDeleteRegion: action("DELETE_REGION", "region"),
|
|
183
|
+
onBeginBoxTransform: action("BEGIN_BOX_TRANSFORM", "box", "directions"),
|
|
184
|
+
onBeginMovePolygonPoint: action("BEGIN_MOVE_POLYGON_POINT", "polygon", "pointIndex"),
|
|
185
|
+
onBeginMoveKeypoint: action("BEGIN_MOVE_KEYPOINT", "region", "keypointId"),
|
|
186
|
+
onAddPolygonPoint: action("ADD_POLYGON_POINT", "polygon", "point", "pointIndex"),
|
|
187
|
+
onSelectRegion: action("SELECT_REGION", "region"),
|
|
188
|
+
onBeginMovePoint: action("BEGIN_MOVE_POINT", "point"),
|
|
189
|
+
onImageLoaded: action("IMAGE_LOADED", "image"),
|
|
190
|
+
RegionEditLabel: RegionEditLabel,
|
|
191
|
+
onImageOrVideoLoaded: action("IMAGE_OR_VIDEO_LOADED", "metadata"),
|
|
192
|
+
onChangeVideoTime: action("CHANGE_VIDEO_TIME", "newTime"),
|
|
193
|
+
onChangeVideoPlaying: action("CHANGE_VIDEO_PLAYING", "isPlaying"),
|
|
194
|
+
onRegionClassAdded: onRegionClassAdded,
|
|
195
|
+
allowComments: state.allowComments
|
|
196
|
+
}));
|
|
197
|
+
var onClickIconSidebarItem = useEventCallback(function (item) {
|
|
198
|
+
dispatch({
|
|
199
|
+
type: "SELECT_TOOL",
|
|
200
|
+
selectedTool: item.name
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
var onClickHeaderItem = useEventCallback(function (item) {
|
|
204
|
+
if (item.name === "Fullscreen") {
|
|
205
|
+
fullScreenHandle.enter();
|
|
206
|
+
} else if (item.name === "Window") {
|
|
207
|
+
fullScreenHandle.exit();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
dispatch({
|
|
211
|
+
type: "HEADER_BUTTON_CLICKED",
|
|
212
|
+
buttonName: item.name
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
var debugModeOn = Boolean(window.localStorage.$ANNOTATE_DEBUG_MODE && state);
|
|
216
|
+
var nextImageHasRegions = !nextImage || nextImage.regions && nextImage.regions.length > 0;
|
|
217
|
+
return React.createElement(ThemeProvider, {
|
|
218
|
+
theme: theme
|
|
219
|
+
}, React.createElement(FullScreenContainer, null, React.createElement(FullScreen, {
|
|
220
|
+
handle: fullScreenHandle,
|
|
221
|
+
onChange: function onChange(open) {
|
|
222
|
+
if (!open) {
|
|
223
|
+
fullScreenHandle.exit();
|
|
224
|
+
action("HEADER_BUTTON_CLICKED", "buttonName")("Window");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}, React.createElement(HotkeyDiv, {
|
|
228
|
+
tabIndex: -1,
|
|
229
|
+
divRef: innerContainerRef,
|
|
230
|
+
onMouseDown: refocusOnMouseEvent,
|
|
231
|
+
onMouseOver: refocusOnMouseEvent,
|
|
232
|
+
allowChanges: true,
|
|
233
|
+
handlers: hotkeyHandlers,
|
|
234
|
+
className: classnames(classes.container, state.fullScreen && "Fullscreen")
|
|
235
|
+
}, React.createElement(Workspace, {
|
|
236
|
+
allowFullscreen: true,
|
|
237
|
+
iconDictionary: iconDictionary,
|
|
238
|
+
hideHeader: hideHeader,
|
|
239
|
+
hideHeaderText: hideHeaderText,
|
|
240
|
+
headerLeftSide: [state.annotationType === "video" ? React.createElement(KeyframeTimeline, {
|
|
241
|
+
currentTime: state.currentVideoTime,
|
|
242
|
+
duration: state.videoDuration,
|
|
243
|
+
onChangeCurrentTime: action("CHANGE_VIDEO_TIME", "newTime"),
|
|
244
|
+
keyframes: state.keyframes
|
|
245
|
+
}) : activeImage ? React.createElement("div", {
|
|
246
|
+
className: classes.headerTitle
|
|
247
|
+
}, activeImage.name) : null].filter(Boolean),
|
|
248
|
+
headerItems: [!hidePrev && {
|
|
249
|
+
name: "Prev"
|
|
250
|
+
}, !hideNext && {
|
|
251
|
+
name: "Next"
|
|
252
|
+
}, state.annotationType !== "video" ? null : !state.videoPlaying ? {
|
|
253
|
+
name: "Play"
|
|
254
|
+
} : {
|
|
255
|
+
name: "Pause"
|
|
256
|
+
}, !hideClone && !nextImageHasRegions && activeImage.regions && {
|
|
257
|
+
name: "Clone"
|
|
258
|
+
}, !hideSettings && {
|
|
259
|
+
name: "Settings"
|
|
260
|
+
}, !hideFullScreen && (state.fullScreen ? {
|
|
261
|
+
name: "Window"
|
|
262
|
+
} : {
|
|
263
|
+
name: "Fullscreen"
|
|
264
|
+
}), !hideSave && {
|
|
265
|
+
name: "Save"
|
|
266
|
+
}].filter(Boolean),
|
|
267
|
+
onClickHeaderItem: onClickHeaderItem,
|
|
268
|
+
onClickIconSidebarItem: onClickIconSidebarItem,
|
|
269
|
+
selectedTools: [state.selectedTool, state.showTags && "show-tags", state.showMask && "show-mask"].filter(Boolean),
|
|
270
|
+
iconSidebarItems: [{
|
|
271
|
+
name: "select",
|
|
272
|
+
helperText: "Select" + getHotkeyHelpText("select_tool"),
|
|
273
|
+
alwaysShowing: true
|
|
274
|
+
}, {
|
|
275
|
+
name: "pan",
|
|
276
|
+
helperText: "Drag/Pan (right or middle click)" + getHotkeyHelpText("pan_tool"),
|
|
277
|
+
alwaysShowing: true
|
|
278
|
+
}, {
|
|
279
|
+
name: "zoom",
|
|
280
|
+
helperText: "Zoom In/Out (scroll)" + getHotkeyHelpText("zoom_tool"),
|
|
281
|
+
alwaysShowing: true
|
|
282
|
+
}, {
|
|
283
|
+
name: "show-tags",
|
|
284
|
+
helperText: "Show / Hide Tags",
|
|
285
|
+
alwaysShowing: true
|
|
286
|
+
}, {
|
|
287
|
+
name: "create-point",
|
|
288
|
+
helperText: "Add Point" + getHotkeyHelpText("create_point")
|
|
289
|
+
}, {
|
|
290
|
+
name: "create-box",
|
|
291
|
+
helperText: "Add Bounding Box" + getHotkeyHelpText("create_bounding_box")
|
|
292
|
+
}, {
|
|
293
|
+
name: "create-polygon",
|
|
294
|
+
helperText: "Add Polygon" + getHotkeyHelpText("create_polygon")
|
|
295
|
+
}, {
|
|
296
|
+
name: "create-line",
|
|
297
|
+
helperText: "Add Line"
|
|
298
|
+
}, {
|
|
299
|
+
name: "create-expanding-line",
|
|
300
|
+
helperText: "Add Expanding Line"
|
|
301
|
+
}, {
|
|
302
|
+
name: "create-keypoints",
|
|
303
|
+
helperText: "Add Keypoints (Pose)"
|
|
304
|
+
}, state.fullImageSegmentationMode && {
|
|
305
|
+
name: "show-mask",
|
|
306
|
+
alwaysShowing: true,
|
|
307
|
+
helperText: "Show / Hide Mask"
|
|
308
|
+
}, {
|
|
309
|
+
name: "modify-allowed-area",
|
|
310
|
+
helperText: "Modify Allowed Area"
|
|
311
|
+
}].filter(Boolean).filter(function (a) {
|
|
312
|
+
return a.alwaysShowing || state.enabledTools.includes(a.name);
|
|
313
|
+
}),
|
|
314
|
+
rightSidebarItems: [debugModeOn && React.createElement(DebugBox, {
|
|
315
|
+
state: debugModeOn,
|
|
316
|
+
lastAction: state.lastAction
|
|
317
|
+
}), state.taskDescription && React.createElement(TaskDescription, {
|
|
318
|
+
description: state.taskDescription
|
|
319
|
+
}), state.regionClsList && React.createElement(ClassSelectionMenu, {
|
|
320
|
+
selectedCls: state.selectedCls,
|
|
321
|
+
regionClsList: state.regionClsList,
|
|
322
|
+
onSelectCls: action("SELECT_CLASSIFICATION", "cls")
|
|
323
|
+
}), state.labelImages && React.createElement(TagsSidebarBox, {
|
|
324
|
+
currentImage: activeImage,
|
|
325
|
+
imageClsList: state.imageClsList,
|
|
326
|
+
imageTagList: state.imageTagList,
|
|
327
|
+
onChangeImage: action("CHANGE_IMAGE", "delta"),
|
|
328
|
+
expandedByDefault: true
|
|
329
|
+
}), // (state.images?.length || 0) > 1 && (
|
|
330
|
+
// <ImageSelector
|
|
331
|
+
// onSelect={action("SELECT_REGION", "region")}
|
|
332
|
+
// images={state.images}
|
|
333
|
+
// />
|
|
334
|
+
// ),
|
|
335
|
+
groups && React.createElement(GroupSelector, {
|
|
336
|
+
title: "Articles",
|
|
337
|
+
groups: groups,
|
|
338
|
+
selectedGroupId: selectedGroupId,
|
|
339
|
+
onSelect: onGroupSelect
|
|
340
|
+
}), React.createElement(RegionSelector, {
|
|
341
|
+
regions: activeImage ? activeImage.regions : emptyArr,
|
|
342
|
+
onSelectRegion: action("SELECT_REGION", "region"),
|
|
343
|
+
onDeleteRegion: action("DELETE_REGION", "region"),
|
|
344
|
+
onChangeRegion: action("CHANGE_REGION", "region")
|
|
345
|
+
}), state.keyframes && React.createElement(KeyframesSelector, {
|
|
346
|
+
onChangeVideoTime: action("CHANGE_VIDEO_TIME", "newTime"),
|
|
347
|
+
onDeleteKeyframe: action("DELETE_KEYFRAME", "time"),
|
|
348
|
+
onChangeCurrentTime: action("CHANGE_VIDEO_TIME", "newTime"),
|
|
349
|
+
currentTime: state.currentVideoTime,
|
|
350
|
+
duration: state.videoDuration,
|
|
351
|
+
keyframes: state.keyframes
|
|
352
|
+
}), !hideHistory && React.createElement(HistorySidebarBox, {
|
|
353
|
+
history: state.history,
|
|
354
|
+
onRestoreHistory: action("RESTORE_HISTORY")
|
|
355
|
+
})].filter(Boolean)
|
|
356
|
+
}, canvas), React.createElement(SettingsDialog, {
|
|
357
|
+
open: state.settingsOpen,
|
|
358
|
+
onClose: function onClose() {
|
|
359
|
+
return dispatch({
|
|
360
|
+
type: "HEADER_BUTTON_CLICKED",
|
|
361
|
+
buttonName: "Settings"
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
})))));
|
|
365
|
+
};
|
|
366
|
+
export default MainLayout;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { grey } from "@mui/material/colors"
|
|
2
|
-
|
|
1
|
+
import { grey } from "@mui/material/colors";
|
|
3
2
|
export default {
|
|
4
3
|
container: {
|
|
5
4
|
display: "flex",
|
|
@@ -15,12 +14,12 @@ export default {
|
|
|
15
14
|
left: 0,
|
|
16
15
|
right: 0,
|
|
17
16
|
top: 0,
|
|
18
|
-
bottom: 0
|
|
19
|
-
}
|
|
17
|
+
bottom: 0
|
|
18
|
+
}
|
|
20
19
|
},
|
|
21
20
|
headerTitle: {
|
|
22
21
|
fontWeight: "bold",
|
|
23
22
|
color: grey[700],
|
|
24
|
-
paddingLeft: 16
|
|
25
|
-
}
|
|
26
|
-
}
|
|
23
|
+
paddingLeft: 16
|
|
24
|
+
}
|
|
25
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import getImpliedVideoRegions from "../Annotator/reducers/get-implied-video-regions.js";
|
|
3
|
+
var emptyArr = [];
|
|
4
|
+
export default (function (state) {
|
|
5
|
+
if (state.annotationType !== "video") return emptyArr;
|
|
6
|
+
var keyframes = state.keyframes,
|
|
7
|
+
_state$currentVideoTi = state.currentVideoTime,
|
|
8
|
+
currentVideoTime = _state$currentVideoTi === void 0 ? 0 : _state$currentVideoTi; // TODO memoize
|
|
9
|
+
|
|
10
|
+
return useMemo(function () {
|
|
11
|
+
return getImpliedVideoRegions(keyframes, currentVideoTime);
|
|
12
|
+
}, [keyframes, currentVideoTime]);
|
|
13
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { styled } from "@mui/material/styles";
|
|
3
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
4
|
+
var theme = createTheme();
|
|
5
|
+
var Svg = styled("svg")(function (_ref) {
|
|
6
|
+
var theme = _ref.theme;
|
|
7
|
+
return {
|
|
8
|
+
pointerEvents: "none",
|
|
9
|
+
position: "absolute",
|
|
10
|
+
zIndex: 1,
|
|
11
|
+
left: 0,
|
|
12
|
+
top: 0,
|
|
13
|
+
width: "100%",
|
|
14
|
+
height: "100%",
|
|
15
|
+
"& text": {
|
|
16
|
+
fill: "#fff"
|
|
17
|
+
},
|
|
18
|
+
"& path": {
|
|
19
|
+
vectorEffect: "non-scaling-stroke",
|
|
20
|
+
strokeWidth: 2,
|
|
21
|
+
opacity: 0.5,
|
|
22
|
+
stroke: "#FFF",
|
|
23
|
+
fill: "none",
|
|
24
|
+
strokeDasharray: 5,
|
|
25
|
+
animationDuration: "4s",
|
|
26
|
+
animationTimingFunction: "linear",
|
|
27
|
+
animationIterationCount: "infinite",
|
|
28
|
+
animationPlayState: "running"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
export var PointDistances = function PointDistances(_ref2) {
|
|
33
|
+
var projectRegionBox = _ref2.projectRegionBox,
|
|
34
|
+
regions = _ref2.regions,
|
|
35
|
+
pointDistancePrecision = _ref2.pointDistancePrecision,
|
|
36
|
+
realSize = _ref2.realSize;
|
|
37
|
+
return React.createElement(ThemeProvider, {
|
|
38
|
+
theme: theme
|
|
39
|
+
}, React.createElement(Svg, null, regions.filter(function (r1) {
|
|
40
|
+
return r1.type === "point";
|
|
41
|
+
}).flatMap(function (r1, i1) {
|
|
42
|
+
return regions.filter(function (r2, i2) {
|
|
43
|
+
return i2 > i1;
|
|
44
|
+
}).filter(function (r2) {
|
|
45
|
+
return r2.type === "point";
|
|
46
|
+
}).map(function (r2) {
|
|
47
|
+
var pr1 = projectRegionBox(r1);
|
|
48
|
+
var pr2 = projectRegionBox(r2);
|
|
49
|
+
var prm = {
|
|
50
|
+
x: (pr1.x + pr1.w / 2 + pr2.x + pr2.w / 2) / 2,
|
|
51
|
+
y: (pr1.y + pr1.h / 2 + pr2.y + pr2.h / 2) / 2
|
|
52
|
+
};
|
|
53
|
+
var displayDistance;
|
|
54
|
+
|
|
55
|
+
if (realSize) {
|
|
56
|
+
var w = realSize.w,
|
|
57
|
+
h = realSize.h,
|
|
58
|
+
unitName = realSize.unitName;
|
|
59
|
+
displayDistance = Math.sqrt(Math.pow(r1.x * w - r2.x * w, 2) + Math.pow(r1.y * h - r2.y * h, 2)).toFixed(pointDistancePrecision) + unitName;
|
|
60
|
+
} else {
|
|
61
|
+
displayDistance = (Math.sqrt(Math.pow(r1.x - r2.x, 2) + Math.pow(r1.y - r2.y, 2)) * 100).toFixed(pointDistancePrecision) + "%";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return React.createElement(Fragment, null, React.createElement("path", {
|
|
65
|
+
d: "M".concat(pr1.x + pr1.w / 2, ",").concat(pr1.y + pr1.h / 2, " L").concat(pr2.x + pr2.w / 2, ",").concat(pr2.y + pr2.h / 2)
|
|
66
|
+
}), React.createElement("text", {
|
|
67
|
+
x: prm.x,
|
|
68
|
+
y: prm.y
|
|
69
|
+
}, displayDistance));
|
|
70
|
+
});
|
|
71
|
+
})));
|
|
72
|
+
};
|
|
73
|
+
export default PointDistances;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import React, { useState } from "react";
|
|
4
|
+
import { RemoveScroll } from "react-remove-scroll";
|
|
5
|
+
import { styled } from "@mui/material/styles";
|
|
6
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
7
|
+
import useEventCallback from "use-event-callback";
|
|
8
|
+
var theme = createTheme();
|
|
9
|
+
var Container = styled("div")(function (_ref) {
|
|
10
|
+
var theme = _ref.theme;
|
|
11
|
+
return {
|
|
12
|
+
"& > div": {
|
|
13
|
+
width: "100%",
|
|
14
|
+
height: "100%"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
export var PreventScrollToParents = function PreventScrollToParents(_ref2) {
|
|
19
|
+
var children = _ref2.children,
|
|
20
|
+
otherProps = _objectWithoutProperties(_ref2, ["children"]);
|
|
21
|
+
|
|
22
|
+
var _useState = useState(false),
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
mouseOver = _useState2[0],
|
|
25
|
+
changeMouseOver = _useState2[1];
|
|
26
|
+
|
|
27
|
+
var onMouseMove = useEventCallback(function (e) {
|
|
28
|
+
if (!mouseOver) changeMouseOver(true);
|
|
29
|
+
|
|
30
|
+
if (otherProps.onMouseMove) {
|
|
31
|
+
otherProps.onMouseMove(e);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var onMouseLeave = useEventCallback(function (e) {
|
|
35
|
+
setTimeout(function () {
|
|
36
|
+
if (mouseOver) {
|
|
37
|
+
changeMouseOver(false);
|
|
38
|
+
}
|
|
39
|
+
}, 100);
|
|
40
|
+
});
|
|
41
|
+
return React.createElement(ThemeProvider, {
|
|
42
|
+
theme: theme
|
|
43
|
+
}, React.createElement(Container, Object.assign({}, otherProps, {
|
|
44
|
+
onMouseMove: onMouseMove,
|
|
45
|
+
onMouseLeave: onMouseLeave
|
|
46
|
+
}), React.createElement(RemoveScroll, {
|
|
47
|
+
enabled: mouseOver,
|
|
48
|
+
removeScrollBar: false
|
|
49
|
+
}, children)));
|
|
50
|
+
};
|
|
51
|
+
export default PreventScrollToParents;
|