@searpent/react-image-annotate 2.0.5 → 2.0.6
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/examplePhotos.js +6976 -0
- package/Annotator/index.js +262 -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 +1152 -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/Editor/annotation-plugin/annotation.js +613 -0
- package/Editor/index.js +57 -0
- package/{src/Editor → Editor}/tools.js +2 -3
- 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 +429 -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 +469 -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/MetadataEditorSidebarBox/index.js +126 -0
- package/PageSelector/index.js +67 -0
- package/PointDistances/index.js +73 -0
- package/PreventScrollToParents/index.js +51 -0
- package/RegionLabel/index.js +205 -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 +294 -0
- package/RegionTags/index.js +142 -0
- package/SettingsDialog/index.js +52 -0
- package/SettingsProvider/index.js +58 -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-colors.js +101 -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/{src/utils → utils}/filter-only-unique.js +1 -1
- 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/photosToImages.js +53 -0
- package/utils/regions-to-blocks.js +16 -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/examplePhotos.js +0 -7601
- package/src/Annotator/index.js +0 -291
- package/src/Annotator/index.story.js +0 -807
- 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 -996
- 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/Editor/annotation-plugin/annotation.css +0 -46
- package/src/Editor/annotation-plugin/annotation.js +0 -515
- package/src/Editor/index.js +0 -24
- 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/GroupSelectorSidebarBox/index.js +0 -48
- 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 -494
- package/src/ImageCanvas/index.story.js +0 -314
- 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 -510
- package/src/MainLayout/index.story.js +0 -240
- package/src/MainLayout/types.js +0 -164
- package/src/MainLayout/use-implied-video-regions.js +0 -17
- package/src/MetadataEditorSidebarBox/index.js +0 -98
- package/src/PageSelector/index.js +0 -76
- package/src/PageSelector/page-selector.css +0 -69
- 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 -222
- package/src/RegionSelectAndTransformBoxes/index.js +0 -234
- package/src/RegionSelectorSidebarBox/index.js +0 -216
- package/src/RegionShapes/index.js +0 -254
- package/src/RegionTags/index.js +0 -134
- package/src/SettingsDialog/index.js +0 -58
- package/src/SettingsProvider/index.js +0 -48
- 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-colors.js +0 -74
- 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/photosToImages.js +0 -40
- package/src/utils/regions-to-blocks.js +0 -14
- package/src/utils/set-in-local-storage.js +0 -6
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
+
import React, { useEffect, useReducer } from "react";
|
|
6
|
+
import makeImmutable, { without } from "seamless-immutable";
|
|
7
|
+
import MainLayout from "../MainLayout";
|
|
8
|
+
import SettingsProvider from "../SettingsProvider";
|
|
9
|
+
import combineReducers from "./reducers/combine-reducers.js";
|
|
10
|
+
import generalReducer from "./reducers/general-reducer.js";
|
|
11
|
+
import getFromLocalStorage from "../utils/get-from-local-storage";
|
|
12
|
+
import historyHandler from "./reducers/history-handler.js";
|
|
13
|
+
import imageReducer from "./reducers/image-reducer.js";
|
|
14
|
+
import useEventCallback from "use-event-callback";
|
|
15
|
+
import videoReducer from "./reducers/video-reducer.js";
|
|
16
|
+
export var Annotator = function Annotator(_ref) {
|
|
17
|
+
var images = _ref.images,
|
|
18
|
+
allowedArea = _ref.allowedArea,
|
|
19
|
+
_ref$selectedImage = _ref.selectedImage,
|
|
20
|
+
selectedImage = _ref$selectedImage === void 0 ? images && images.length > 0 ? 0 : undefined : _ref$selectedImage,
|
|
21
|
+
showPointDistances = _ref.showPointDistances,
|
|
22
|
+
pointDistancePrecision = _ref.pointDistancePrecision,
|
|
23
|
+
_ref$showTags = _ref.showTags,
|
|
24
|
+
showTags = _ref$showTags === void 0 ? getFromLocalStorage("showTags", true) : _ref$showTags,
|
|
25
|
+
_ref$enabledTools = _ref.enabledTools,
|
|
26
|
+
enabledTools = _ref$enabledTools === void 0 ? ["select", "create-point", "create-box", "create-polygon", "create-line", "create-expanding-line", "show-mask"] : _ref$enabledTools,
|
|
27
|
+
_ref$selectedTool = _ref.selectedTool,
|
|
28
|
+
selectedTool = _ref$selectedTool === void 0 ? "select" : _ref$selectedTool,
|
|
29
|
+
_ref$regionTagList = _ref.regionTagList,
|
|
30
|
+
regionTagList = _ref$regionTagList === void 0 ? [] : _ref$regionTagList,
|
|
31
|
+
_ref$regionClsList = _ref.regionClsList,
|
|
32
|
+
regionClsList = _ref$regionClsList === void 0 ? [] : _ref$regionClsList,
|
|
33
|
+
_ref$imageTagList = _ref.imageTagList,
|
|
34
|
+
imageTagList = _ref$imageTagList === void 0 ? [] : _ref$imageTagList,
|
|
35
|
+
_ref$imageClsList = _ref.imageClsList,
|
|
36
|
+
imageClsList = _ref$imageClsList === void 0 ? [] : _ref$imageClsList,
|
|
37
|
+
_ref$keyframes = _ref.keyframes,
|
|
38
|
+
keyframes = _ref$keyframes === void 0 ? {} : _ref$keyframes,
|
|
39
|
+
_ref$taskDescription = _ref.taskDescription,
|
|
40
|
+
taskDescription = _ref$taskDescription === void 0 ? "" : _ref$taskDescription,
|
|
41
|
+
_ref$fullImageSegment = _ref.fullImageSegmentationMode,
|
|
42
|
+
fullImageSegmentationMode = _ref$fullImageSegment === void 0 ? false : _ref$fullImageSegment,
|
|
43
|
+
RegionEditLabel = _ref.RegionEditLabel,
|
|
44
|
+
videoSrc = _ref.videoSrc,
|
|
45
|
+
_ref$videoTime = _ref.videoTime,
|
|
46
|
+
videoTime = _ref$videoTime === void 0 ? 0 : _ref$videoTime,
|
|
47
|
+
videoName = _ref.videoName,
|
|
48
|
+
onExit = _ref.onExit,
|
|
49
|
+
onNextImage = _ref.onNextImage,
|
|
50
|
+
onPrevImage = _ref.onPrevImage,
|
|
51
|
+
keypointDefinitions = _ref.keypointDefinitions,
|
|
52
|
+
_ref$autoSegmentation = _ref.autoSegmentationOptions,
|
|
53
|
+
autoSegmentationOptions = _ref$autoSegmentation === void 0 ? {
|
|
54
|
+
type: "autoseg"
|
|
55
|
+
} : _ref$autoSegmentation,
|
|
56
|
+
hideHeader = _ref.hideHeader,
|
|
57
|
+
hideHeaderText = _ref.hideHeaderText,
|
|
58
|
+
hideNext = _ref.hideNext,
|
|
59
|
+
hidePrev = _ref.hidePrev,
|
|
60
|
+
hideClone = _ref.hideClone,
|
|
61
|
+
hideSettings = _ref.hideSettings,
|
|
62
|
+
hideFullScreen = _ref.hideFullScreen,
|
|
63
|
+
hideSave = _ref.hideSave,
|
|
64
|
+
allowComments = _ref.allowComments,
|
|
65
|
+
onImagesChange = _ref.onImagesChange,
|
|
66
|
+
groups = _ref.groups,
|
|
67
|
+
onGroupSelect = _ref.onGroupSelect,
|
|
68
|
+
hideHistory = _ref.hideHistory,
|
|
69
|
+
hideNotEditingLabel = _ref.hideNotEditingLabel,
|
|
70
|
+
showEditor = _ref.showEditor,
|
|
71
|
+
showPageSelector = _ref.showPageSelector,
|
|
72
|
+
clsColors = _ref.clsColors,
|
|
73
|
+
groupColors = _ref.groupColors,
|
|
74
|
+
onRecalc = _ref.onRecalc,
|
|
75
|
+
onSave = _ref.onSave,
|
|
76
|
+
allowedGroups = _ref.allowedGroups,
|
|
77
|
+
metadata = _ref.metadata;
|
|
78
|
+
|
|
79
|
+
if (typeof selectedImage === "string") {
|
|
80
|
+
selectedImage = (images || []).findIndex(function (img) {
|
|
81
|
+
return img.src === selectedImage;
|
|
82
|
+
});
|
|
83
|
+
if (selectedImage === -1) selectedImage = undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var annotationType = images ? "image" : "video";
|
|
87
|
+
|
|
88
|
+
var _useReducer = useReducer(historyHandler(combineReducers(annotationType === "image" ? imageReducer : videoReducer, generalReducer)), makeImmutable(_objectSpread({
|
|
89
|
+
annotationType: annotationType,
|
|
90
|
+
showTags: showTags,
|
|
91
|
+
allowedArea: allowedArea,
|
|
92
|
+
showPointDistances: showPointDistances,
|
|
93
|
+
pointDistancePrecision: pointDistancePrecision,
|
|
94
|
+
selectedTool: selectedTool,
|
|
95
|
+
fullImageSegmentationMode: fullImageSegmentationMode,
|
|
96
|
+
autoSegmentationOptions: autoSegmentationOptions,
|
|
97
|
+
mode: null,
|
|
98
|
+
taskDescription: taskDescription,
|
|
99
|
+
showMask: true,
|
|
100
|
+
labelImages: imageClsList.length > 0 || imageTagList.length > 0,
|
|
101
|
+
regionClsList: regionClsList,
|
|
102
|
+
regionTagList: regionTagList,
|
|
103
|
+
imageClsList: imageClsList,
|
|
104
|
+
imageTagList: imageTagList,
|
|
105
|
+
currentVideoTime: videoTime,
|
|
106
|
+
enabledTools: enabledTools,
|
|
107
|
+
history: [],
|
|
108
|
+
videoName: videoName,
|
|
109
|
+
keypointDefinitions: keypointDefinitions,
|
|
110
|
+
allowComments: allowComments
|
|
111
|
+
}, annotationType === "image" ? {
|
|
112
|
+
selectedImage: selectedImage,
|
|
113
|
+
images: images,
|
|
114
|
+
selectedImageFrameTime: images && images.length > 0 ? images[0].frameTime : undefined
|
|
115
|
+
} : {
|
|
116
|
+
videoSrc: videoSrc,
|
|
117
|
+
keyframes: keyframes
|
|
118
|
+
}, {
|
|
119
|
+
imagesUpdatedAt: null,
|
|
120
|
+
imagesSavedAt: null,
|
|
121
|
+
metadata: metadata
|
|
122
|
+
}))),
|
|
123
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
124
|
+
state = _useReducer2[0],
|
|
125
|
+
dispatchToReducer = _useReducer2[1];
|
|
126
|
+
|
|
127
|
+
var dispatch = useEventCallback(function (action) {
|
|
128
|
+
if (action.type === "HEADER_BUTTON_CLICKED") {
|
|
129
|
+
if (["Exit", "Done", "Save", "Complete"].includes(action.buttonName)) {
|
|
130
|
+
return onExit(without(state, "history"));
|
|
131
|
+
} else if (action.buttonName === "Next" && onNextImage) {
|
|
132
|
+
return onNextImage(without(state, "history"));
|
|
133
|
+
} else if (action.buttonName === "Prev" && onPrevImage) {
|
|
134
|
+
return onPrevImage(without(state, "history"));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
dispatchToReducer(action);
|
|
139
|
+
});
|
|
140
|
+
var onRegionClassAdded = useEventCallback(function (cls) {
|
|
141
|
+
dispatchToReducer({
|
|
142
|
+
type: "ON_CLS_ADDED",
|
|
143
|
+
cls: cls
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
var handleSaveClick =
|
|
148
|
+
/*#__PURE__*/
|
|
149
|
+
function () {
|
|
150
|
+
var _ref2 = _asyncToGenerator(
|
|
151
|
+
/*#__PURE__*/
|
|
152
|
+
_regeneratorRuntime.mark(function _callee(e) {
|
|
153
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
154
|
+
while (1) {
|
|
155
|
+
switch (_context.prev = _context.next) {
|
|
156
|
+
case 0:
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
|
|
159
|
+
if (onSave) {
|
|
160
|
+
onSave();
|
|
161
|
+
dispatchToReducer({
|
|
162
|
+
type: "IMAGES_SAVED",
|
|
163
|
+
savedAt: new Date()
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
case 2:
|
|
168
|
+
case "end":
|
|
169
|
+
return _context.stop();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}, _callee);
|
|
173
|
+
}));
|
|
174
|
+
|
|
175
|
+
return function handleSaveClick(_x) {
|
|
176
|
+
return _ref2.apply(this, arguments);
|
|
177
|
+
};
|
|
178
|
+
}();
|
|
179
|
+
|
|
180
|
+
var handleRecalcClick = function handleRecalcClick(e) {
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
|
|
183
|
+
if (onRecalc) {
|
|
184
|
+
onRecalc();
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
var handleMetadataChange = function handleMetadataChange(_ref3) {
|
|
189
|
+
var name = _ref3.name,
|
|
190
|
+
value = _ref3.value,
|
|
191
|
+
imageIndex = _ref3.imageIndex;
|
|
192
|
+
dispatchToReducer({
|
|
193
|
+
type: "UPDATE_METADATA",
|
|
194
|
+
name: name,
|
|
195
|
+
value: value,
|
|
196
|
+
imageIndex: imageIndex
|
|
197
|
+
});
|
|
198
|
+
}; // trigger this on every BBox manipulation (there is currently no way to detect adding of new box!)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
useEffect(function () {
|
|
202
|
+
if (!state.lastAction || !["BEGIN_BOX_TRANSFORM", "CHANGE_REGION", "DELETE_REGION"].includes(state.lastAction.type)) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (onImagesChange) {
|
|
207
|
+
onImagesChange(state.images);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
dispatchToReducer({
|
|
211
|
+
type: "IMAGES_UPDATED",
|
|
212
|
+
updatedAt: new Date()
|
|
213
|
+
});
|
|
214
|
+
}, [onImagesChange, state.images, state.lastAction]);
|
|
215
|
+
useEffect(function () {
|
|
216
|
+
if (selectedImage === undefined) return;
|
|
217
|
+
dispatchToReducer({
|
|
218
|
+
type: "SELECT_IMAGE",
|
|
219
|
+
imageIndex: selectedImage,
|
|
220
|
+
image: state.images[selectedImage]
|
|
221
|
+
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
222
|
+
}, [onImagesChange, selectedImage]);
|
|
223
|
+
if (!images && !videoSrc) return 'Missing required prop "images" or "videoSrc"';
|
|
224
|
+
|
|
225
|
+
var _ref4 = state.imagesSavedAt < state.imagesUpdatedAt ? [true, true] : [false, false],
|
|
226
|
+
_ref5 = _slicedToArray(_ref4, 2),
|
|
227
|
+
recalcActive = _ref5[0],
|
|
228
|
+
saveActive = _ref5[1];
|
|
229
|
+
|
|
230
|
+
return React.createElement(SettingsProvider, {
|
|
231
|
+
clsColors: clsColors,
|
|
232
|
+
groupColors: groupColors
|
|
233
|
+
}, React.createElement(MainLayout, {
|
|
234
|
+
RegionEditLabel: RegionEditLabel,
|
|
235
|
+
alwaysShowNextButton: Boolean(onNextImage),
|
|
236
|
+
alwaysShowPrevButton: Boolean(onPrevImage),
|
|
237
|
+
state: state,
|
|
238
|
+
dispatch: dispatch,
|
|
239
|
+
onRegionClassAdded: onRegionClassAdded,
|
|
240
|
+
hideHeader: hideHeader,
|
|
241
|
+
hideHeaderText: hideHeaderText,
|
|
242
|
+
hideNext: hideNext,
|
|
243
|
+
hidePrev: hidePrev,
|
|
244
|
+
hideClone: hideClone,
|
|
245
|
+
hideSettings: hideSettings,
|
|
246
|
+
hideFullScreen: hideFullScreen,
|
|
247
|
+
hideSave: hideSave,
|
|
248
|
+
groups: groups,
|
|
249
|
+
onGroupSelect: onGroupSelect,
|
|
250
|
+
hideHistory: hideHistory,
|
|
251
|
+
hideNotEditingLabel: hideNotEditingLabel,
|
|
252
|
+
showEditor: showEditor,
|
|
253
|
+
showPageSelector: showPageSelector,
|
|
254
|
+
onRecalc: handleRecalcClick,
|
|
255
|
+
onSave: handleSaveClick,
|
|
256
|
+
saveActive: recalcActive,
|
|
257
|
+
recalcActive: saveActive,
|
|
258
|
+
allowedGroups: allowedGroups,
|
|
259
|
+
onMetadataChange: handleMetadataChange
|
|
260
|
+
}));
|
|
261
|
+
};
|
|
262
|
+
export default Annotator;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default (function () {
|
|
2
|
+
for (var _len = arguments.length, reducers = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3
|
+
reducers[_key] = arguments[_key];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return function (state, action) {
|
|
7
|
+
for (var _i = 0, _reducers = reducers; _i < _reducers.length; _i++) {
|
|
8
|
+
var reducer = _reducers[_i];
|
|
9
|
+
state = reducer(state, action);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return state;
|
|
13
|
+
};
|
|
14
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
|
|
4
|
+
function clamp(num, min, max) {
|
|
5
|
+
return num <= min ? min : num >= max ? max : num;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default (function (expandingLine) {
|
|
9
|
+
var expandingWidth = expandingLine.expandingWidth || 0.005;
|
|
10
|
+
var pointPairs = expandingLine.points.map(function (_ref, i) {
|
|
11
|
+
var x = _ref.x,
|
|
12
|
+
y = _ref.y,
|
|
13
|
+
angle = _ref.angle,
|
|
14
|
+
width = _ref.width;
|
|
15
|
+
|
|
16
|
+
if (!angle) {
|
|
17
|
+
var n = expandingLine.points[clamp(i + 1, 0, expandingLine.points.length - 1)];
|
|
18
|
+
var p = expandingLine.points[clamp(i - 1, 0, expandingLine.points.length - 1)];
|
|
19
|
+
angle = Math.atan2(p.x - n.x, p.y - n.y) + Math.PI / 2;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var dx = Math.sin(angle) * (width || expandingWidth) / 2;
|
|
23
|
+
var dy = Math.cos(angle) * (width || expandingWidth) / 2;
|
|
24
|
+
return [{
|
|
25
|
+
x: x + dx,
|
|
26
|
+
y: y + dy
|
|
27
|
+
}, {
|
|
28
|
+
x: x - dx,
|
|
29
|
+
y: y - dy
|
|
30
|
+
}];
|
|
31
|
+
});
|
|
32
|
+
var firstSection = pointPairs.map(function (_ref2) {
|
|
33
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
34
|
+
p1 = _ref3[0],
|
|
35
|
+
p2 = _ref3[1];
|
|
36
|
+
|
|
37
|
+
return p1;
|
|
38
|
+
});
|
|
39
|
+
var secondSection = pointPairs.map(function (_ref4) {
|
|
40
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
41
|
+
p1 = _ref5[0],
|
|
42
|
+
p2 = _ref5[1];
|
|
43
|
+
|
|
44
|
+
return p2;
|
|
45
|
+
}).asMutable();
|
|
46
|
+
secondSection.reverse();
|
|
47
|
+
var newPoints = firstSection.concat(secondSection).map(function (_ref6) {
|
|
48
|
+
var x = _ref6.x,
|
|
49
|
+
y = _ref6.y;
|
|
50
|
+
return [x, y];
|
|
51
|
+
});
|
|
52
|
+
return _objectSpread({}, expandingLine, {
|
|
53
|
+
type: "polygon",
|
|
54
|
+
open: false,
|
|
55
|
+
points: newPoints,
|
|
56
|
+
unfinished: undefined,
|
|
57
|
+
candidatePoint: undefined // let { expandingWidth = 0.005, points } = region
|
|
58
|
+
// expandingWidth = points.slice(-1)[0].width || expandingWidth
|
|
59
|
+
// const lastPoint = points.slice(-1)[0]
|
|
60
|
+
// return (
|
|
61
|
+
// <>
|
|
62
|
+
// <polygon
|
|
63
|
+
// points={
|
|
64
|
+
// .map((p) => `${p.x * iw} ${p.y * ih}`)
|
|
65
|
+
// .join(" ")}
|
|
66
|
+
// return {
|
|
67
|
+
// ...expandingLine,
|
|
68
|
+
// unfinished: undefined,
|
|
69
|
+
// candidatePoint: undefined,
|
|
70
|
+
// }
|
|
71
|
+
|
|
72
|
+
});
|
|
73
|
+
});
|