@searpent/react-image-annotate 2.0.77 → 2.0.79
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.js +41 -0
- package/Annotator/examplePhotos.js +6980 -0
- package/Annotator/index.js +417 -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 +1430 -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 +140 -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 +702 -0
- package/Editor/index.js +93 -0
- package/Editor/readOnly.js +123 -0
- package/{src/Editor → Editor}/tools.js +2 -3
- package/Errorer/index.js +11 -0
- package/FullImageSegmentationAnnotator/index.js +7 -0
- package/GroupSelectorSidebarBox/index.js +63 -0
- package/GroupsEditorSidebarBox/index.js +138 -0
- package/HelpSidebarBox/index.js +58 -0
- package/HighlightBox/index.js +102 -0
- package/HistorySidebarBox/index.js +71 -0
- package/ImageCanvas/index.js +441 -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/Locker/index.js +11 -0
- package/MainLayout/RightSidebarItemsWrapper.js +19 -0
- package/MainLayout/icon-dictionary.js +104 -0
- package/MainLayout/index.js +526 -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 +231 -0
- package/PageSelector/index.js +180 -0
- package/PointDistances/index.js +73 -0
- package/PreventScrollToParents/index.js +51 -0
- package/RegionLabel/index.js +232 -0
- package/{src/RegionLabel → RegionLabel}/styles.js +12 -15
- package/RegionSelectAndTransformBoxes/index.js +169 -0
- package/RegionSelectorSidebarBox/index.js +254 -0
- package/{src/RegionSelectorSidebarBox → RegionSelectorSidebarBox}/styles.js +13 -14
- package/RegionShapes/index.js +294 -0
- package/RegionTags/index.js +144 -0
- package/SettingsDialog/index.js +52 -0
- package/SettingsProvider/index.js +60 -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 +127 -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/blocks-to-article.js +60 -0
- package/{src/utils → utils}/blocks-to-article.test.js +5 -8
- package/{src/utils → utils}/default-locked-until.js +2 -1
- 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 +85 -0
- package/utils/regions-groups.js +28 -0
- package/utils/regions-to-blocks.js +18 -0
- package/utils/saveable-actions-enum.js +3 -0
- package/utils/set-in-local-storage.js +3 -0
- package/utils/sleep.js +7 -0
- package/utils/uuid-to-hash.js +5 -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/exampleImages.js +0 -48
- package/src/Annotator/examplePhotos.js +0 -7603
- package/src/Annotator/index.js +0 -380
- package/src/Annotator/index.story.js +0 -899
- 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 -1228
- 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 -112
- 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.js +0 -546
- package/src/Editor/index.js +0 -50
- package/src/Editor/readOnly.js +0 -31
- package/src/Errorer/index.js +0 -13
- 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/GroupsEditorSidebarBox/index.js +0 -108
- package/src/HelpSidebarBox/index.js +0 -43
- 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 -515
- 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/Locker/index.js +0 -13
- package/src/MainLayout/RightSidebarItemsWrapper.js +0 -21
- package/src/MainLayout/icon-dictionary.js +0 -79
- package/src/MainLayout/index.js +0 -564
- package/src/MainLayout/index.story.js +0 -240
- package/src/MainLayout/types.js +0 -171
- package/src/MainLayout/use-implied-video-regions.js +0 -17
- package/src/MetadataEditorSidebarBox/index.js +0 -160
- package/src/PageSelector/index.js +0 -159
- 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 -236
- package/src/RegionSelectAndTransformBoxes/index.js +0 -236
- package/src/RegionSelectorSidebarBox/index.js +0 -220
- package/src/RegionShapes/index.js +0 -254
- package/src/RegionTags/index.js +0 -136
- package/src/SettingsDialog/index.js +0 -58
- package/src/SettingsProvider/index.js +0 -57
- 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 -95
- 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/blocks-to-article.js +0 -61
- 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 -67
- package/src/utils/regions-groups.js +0 -19
- package/src/utils/regions-to-blocks.js +0 -16
- package/src/utils/saveable-actions-enum.js +0 -5
- package/src/utils/set-in-local-storage.js +0 -6
- package/src/utils/sleep.js +0 -3
- package/src/utils/uuid-to-hash.js +0 -5
- /package/{src/Editor → Editor}/annotation-plugin/annotation.css +0 -0
- /package/{src/Errorer → Errorer}/errorer.css +0 -0
- /package/{src/Locker → Locker}/locker.css +0 -0
- /package/{src/PageSelector → PageSelector}/page-selector.css +0 -0
- /package/{src/utils → utils}/next-group-id.js +0 -0
package/src/RegionTags/index.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
// @flow weak
|
|
2
|
-
|
|
3
|
-
import React from "react"
|
|
4
|
-
import Paper from "@mui/material/Paper"
|
|
5
|
-
import DefaultRegionLabel from "../RegionLabel"
|
|
6
|
-
import LockIcon from "@mui/icons-material/Lock"
|
|
7
|
-
|
|
8
|
-
const copyWithout = (obj, ...args) => {
|
|
9
|
-
const newObj = { ...obj }
|
|
10
|
-
for (const arg of args) {
|
|
11
|
-
delete newObj[arg]
|
|
12
|
-
}
|
|
13
|
-
return newObj
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const RegionTags = ({
|
|
17
|
-
regions,
|
|
18
|
-
projectRegionBox,
|
|
19
|
-
mouseEvents,
|
|
20
|
-
regionClsList,
|
|
21
|
-
regionTagList,
|
|
22
|
-
onBeginRegionEdit,
|
|
23
|
-
onChangeRegion,
|
|
24
|
-
onCloseRegionEdit,
|
|
25
|
-
onDeleteRegion,
|
|
26
|
-
onDeleteGroup,
|
|
27
|
-
layoutParams,
|
|
28
|
-
imageSrc,
|
|
29
|
-
RegionEditLabel,
|
|
30
|
-
onRegionClassAdded,
|
|
31
|
-
allowComments,
|
|
32
|
-
hideNotEditingLabel,
|
|
33
|
-
allowedGroups
|
|
34
|
-
}) => {
|
|
35
|
-
const RegionLabel =
|
|
36
|
-
RegionEditLabel != null ? RegionEditLabel : DefaultRegionLabel
|
|
37
|
-
return regions
|
|
38
|
-
.filter((r) => r.visible || r.visible === undefined)
|
|
39
|
-
.map((region) => {
|
|
40
|
-
const pbox = projectRegionBox(region)
|
|
41
|
-
const { iw, ih } = layoutParams.current
|
|
42
|
-
let margin = 8
|
|
43
|
-
if (region.highlighted && region.type === "box") margin += 6
|
|
44
|
-
const labelBoxHeight =
|
|
45
|
-
region.editingLabels && !region.locked ? 170 : region.tags ? 60 : 50
|
|
46
|
-
const displayOnTop = pbox.y > labelBoxHeight
|
|
47
|
-
|
|
48
|
-
const coords = displayOnTop
|
|
49
|
-
? {
|
|
50
|
-
left: pbox.x,
|
|
51
|
-
top: pbox.y - margin / 2,
|
|
52
|
-
}
|
|
53
|
-
: { left: pbox.x, top: pbox.y + pbox.h + margin / 2 }
|
|
54
|
-
if (region.locked) {
|
|
55
|
-
return (
|
|
56
|
-
<div
|
|
57
|
-
key={region.id}
|
|
58
|
-
style={{
|
|
59
|
-
position: "absolute",
|
|
60
|
-
...coords,
|
|
61
|
-
zIndex: 10 + (region.editingLabels ? 5 : 0),
|
|
62
|
-
}}
|
|
63
|
-
>
|
|
64
|
-
<Paper
|
|
65
|
-
style={{
|
|
66
|
-
position: "absolute",
|
|
67
|
-
left: 0,
|
|
68
|
-
...(displayOnTop ? { bottom: 0 } : { top: 0 }),
|
|
69
|
-
zIndex: 10,
|
|
70
|
-
backgroundColor: "#fff",
|
|
71
|
-
borderRadius: 4,
|
|
72
|
-
padding: 2,
|
|
73
|
-
paddingBottom: 0,
|
|
74
|
-
opacity: 0.5,
|
|
75
|
-
pointerEvents: "none",
|
|
76
|
-
}}
|
|
77
|
-
>
|
|
78
|
-
<LockIcon style={{ width: 16, height: 16, color: "#333" }} />
|
|
79
|
-
</Paper>
|
|
80
|
-
</div>
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
return (
|
|
84
|
-
<div
|
|
85
|
-
key={region.id}
|
|
86
|
-
style={{
|
|
87
|
-
position: "absolute",
|
|
88
|
-
...coords,
|
|
89
|
-
zIndex: 10 + (region.editingLabels ? 5 : 0),
|
|
90
|
-
width: 200,
|
|
91
|
-
}}
|
|
92
|
-
onMouseDown={(e) => e.preventDefault()}
|
|
93
|
-
onMouseUp={(e) => e.preventDefault()}
|
|
94
|
-
onMouseEnter={(e) => {
|
|
95
|
-
if (region.editingLabels) {
|
|
96
|
-
mouseEvents.onMouseUp(e)
|
|
97
|
-
e.button = 1
|
|
98
|
-
mouseEvents.onMouseUp(e)
|
|
99
|
-
}
|
|
100
|
-
}}
|
|
101
|
-
>
|
|
102
|
-
<div
|
|
103
|
-
style={{
|
|
104
|
-
position: "absolute",
|
|
105
|
-
zIndex: 20,
|
|
106
|
-
left: 0,
|
|
107
|
-
...(displayOnTop ? { bottom: 0 } : { top: 0 }),
|
|
108
|
-
}}
|
|
109
|
-
{...(!region.editingLabels
|
|
110
|
-
? copyWithout(mouseEvents, "onMouseDown", "onMouseUp")
|
|
111
|
-
: {})}
|
|
112
|
-
>
|
|
113
|
-
<RegionLabel
|
|
114
|
-
allowedClasses={regionClsList}
|
|
115
|
-
allowedTags={regionTagList}
|
|
116
|
-
onOpen={onBeginRegionEdit}
|
|
117
|
-
onChange={onChangeRegion}
|
|
118
|
-
onClose={onCloseRegionEdit}
|
|
119
|
-
onDelete={onDeleteRegion}
|
|
120
|
-
onDeleteGroup={onDeleteGroup}
|
|
121
|
-
editing={region.editingLabels}
|
|
122
|
-
region={region}
|
|
123
|
-
regions={regions}
|
|
124
|
-
imageSrc={imageSrc}
|
|
125
|
-
onRegionClassAdded={onRegionClassAdded}
|
|
126
|
-
allowComments={allowComments}
|
|
127
|
-
hideNotEditingLabel={hideNotEditingLabel}
|
|
128
|
-
allowedGroups={allowedGroups}
|
|
129
|
-
/>
|
|
130
|
-
</div>
|
|
131
|
-
</div>
|
|
132
|
-
)
|
|
133
|
-
})
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export default RegionTags
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import React from "react"
|
|
4
|
-
import Dialog from "@mui/material/Dialog"
|
|
5
|
-
import DialogTitle from "@mui/material/DialogTitle"
|
|
6
|
-
import DialogContent from "@mui/material/DialogContent"
|
|
7
|
-
import DialogActions from "@mui/material/DialogActions"
|
|
8
|
-
import Button from "@mui/material/Button"
|
|
9
|
-
import Survey from "material-survey/components/Survey"
|
|
10
|
-
import { useSettings } from "../SettingsProvider"
|
|
11
|
-
|
|
12
|
-
export const SettingsDialog = ({ open, onClose }) => {
|
|
13
|
-
const settings = useSettings()
|
|
14
|
-
return (
|
|
15
|
-
<Dialog open={open || false} onClose={onClose}>
|
|
16
|
-
<DialogTitle>Settings</DialogTitle>
|
|
17
|
-
<DialogContent style={{ minWidth: 400 }}>
|
|
18
|
-
<Survey
|
|
19
|
-
variant="flat"
|
|
20
|
-
noActions
|
|
21
|
-
defaultAnswers={settings}
|
|
22
|
-
onQuestionChange={(q, a, answers) => settings.changeSetting(q, a)}
|
|
23
|
-
form={{
|
|
24
|
-
questions: [
|
|
25
|
-
{
|
|
26
|
-
type: "boolean",
|
|
27
|
-
title: "Show Crosshairs",
|
|
28
|
-
name: "showCrosshairs",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
type: "boolean",
|
|
32
|
-
title: "Show Highlight Box",
|
|
33
|
-
name: "showHighlightBox",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
type: "boolean",
|
|
37
|
-
title: "WASD Mode",
|
|
38
|
-
name: "wasdMode",
|
|
39
|
-
},
|
|
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
|
-
}}
|
|
49
|
-
/>
|
|
50
|
-
</DialogContent>
|
|
51
|
-
<DialogActions>
|
|
52
|
-
<Button onClick={onClose}>Close</Button>
|
|
53
|
-
</DialogActions>
|
|
54
|
-
</Dialog>
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default SettingsDialog
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import React, { createContext, useContext, useState } from "react"
|
|
4
|
-
|
|
5
|
-
const defaultSettings = {
|
|
6
|
-
showCrosshairs: false,
|
|
7
|
-
showHighlightBox: true,
|
|
8
|
-
wasdMode: true,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const DEFAULT_GROUP_COLORS = [
|
|
12
|
-
"#3853F1",
|
|
13
|
-
"#F6E54C",
|
|
14
|
-
"#39D33C",
|
|
15
|
-
"#CF24CF",
|
|
16
|
-
"#22E3ED",
|
|
17
|
-
"#EF3029",
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
export const SettingsContext = createContext(defaultSettings)
|
|
21
|
-
|
|
22
|
-
const pullSettingsFromLocalStorage = () => {
|
|
23
|
-
if (!window || !window.localStorage) return {}
|
|
24
|
-
let settings = {}
|
|
25
|
-
for (let i = 0; i < window.localStorage.length; i++) {
|
|
26
|
-
const key = window.localStorage.key(i)
|
|
27
|
-
if (key.startsWith("settings_")) {
|
|
28
|
-
try {
|
|
29
|
-
settings[key.replace("settings_", "")] = JSON.parse(
|
|
30
|
-
window.localStorage.getItem(key)
|
|
31
|
-
)
|
|
32
|
-
} catch (e) { }
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return settings
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const useSettings = () => useContext(SettingsContext)
|
|
39
|
-
|
|
40
|
-
export const SettingsProvider = ({ children, clsColors, groupColors = DEFAULT_GROUP_COLORS }) => {
|
|
41
|
-
const [state, changeState] = useState({
|
|
42
|
-
...() => pullSettingsFromLocalStorage(),
|
|
43
|
-
clsColors,
|
|
44
|
-
groupColors,
|
|
45
|
-
})
|
|
46
|
-
const changeSetting = (setting: string, value: any) => {
|
|
47
|
-
changeState({ ...state, [setting]: value })
|
|
48
|
-
window.localStorage.setItem(`settings_${setting}`, JSON.stringify(value))
|
|
49
|
-
}
|
|
50
|
-
return (
|
|
51
|
-
<SettingsContext.Provider value={{ ...state, changeSetting }}>
|
|
52
|
-
{children}
|
|
53
|
-
</SettingsContext.Provider>
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default SettingsProvider
|
|
@@ -1,44 +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
|
-
|
|
6
|
-
const theme = createTheme()
|
|
7
|
-
const useStyles = makeStyles((theme) => ({
|
|
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
|
-
const ShortcutField = ({ actionId, actionName, keyName, onChangeShortcut }) => {
|
|
24
|
-
const classes = useStyles()
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<ThemeProvider theme={theme}>
|
|
28
|
-
<div className={classes.shortcutKeyFieldWrapper}>
|
|
29
|
-
<TextField
|
|
30
|
-
variant="outlined"
|
|
31
|
-
label={actionName}
|
|
32
|
-
className={classes.shortcutTextfield}
|
|
33
|
-
value={keyName}
|
|
34
|
-
onKeyPress={(e) => {
|
|
35
|
-
onChangeShortcut(actionId, e.key)
|
|
36
|
-
e.stopPropagation()
|
|
37
|
-
}}
|
|
38
|
-
/>
|
|
39
|
-
</div>
|
|
40
|
-
</ThemeProvider>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default ShortcutField
|
package/src/Shortcuts/index.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react"
|
|
2
|
-
import SidebarBoxContainer from "../SidebarBoxContainer"
|
|
3
|
-
import { setIn } from "seamless-immutable"
|
|
4
|
-
import ShortcutField from "./ShortcutField"
|
|
5
|
-
|
|
6
|
-
const defaultShortcuts = {
|
|
7
|
-
select: {
|
|
8
|
-
action: {
|
|
9
|
-
type: "SELECT_TOOL",
|
|
10
|
-
},
|
|
11
|
-
name: "Select Region",
|
|
12
|
-
key: "Escape",
|
|
13
|
-
},
|
|
14
|
-
zoom: {
|
|
15
|
-
action: {
|
|
16
|
-
type: "SELECT_TOOL",
|
|
17
|
-
},
|
|
18
|
-
name: "Zoom In/Out",
|
|
19
|
-
key: "z",
|
|
20
|
-
},
|
|
21
|
-
"create-point": {
|
|
22
|
-
action: {
|
|
23
|
-
type: "SELECT_TOOL",
|
|
24
|
-
},
|
|
25
|
-
name: "Create Point",
|
|
26
|
-
},
|
|
27
|
-
"create-box": {
|
|
28
|
-
action: {
|
|
29
|
-
type: "SELECT_TOOL",
|
|
30
|
-
},
|
|
31
|
-
name: "Add Bounding Box",
|
|
32
|
-
key: "b",
|
|
33
|
-
},
|
|
34
|
-
pan: {
|
|
35
|
-
action: {
|
|
36
|
-
type: "SELECT_TOOL",
|
|
37
|
-
},
|
|
38
|
-
name: "Pan",
|
|
39
|
-
},
|
|
40
|
-
"create-polygon": {
|
|
41
|
-
action: {
|
|
42
|
-
type: "SELECT_TOOL",
|
|
43
|
-
},
|
|
44
|
-
name: "Create Polygon",
|
|
45
|
-
},
|
|
46
|
-
"create-pixel": {
|
|
47
|
-
action: {
|
|
48
|
-
type: "SELECT_TOOL",
|
|
49
|
-
},
|
|
50
|
-
name: "Create Pixel",
|
|
51
|
-
},
|
|
52
|
-
"prev-image": {
|
|
53
|
-
action: {
|
|
54
|
-
type: "HEADER_BUTTON_CLICKED",
|
|
55
|
-
buttonName: "Prev",
|
|
56
|
-
},
|
|
57
|
-
name: "Previous Image",
|
|
58
|
-
key: "a",
|
|
59
|
-
},
|
|
60
|
-
"next-image": {
|
|
61
|
-
action: {
|
|
62
|
-
type: "HEADER_BUTTON_CLICKED",
|
|
63
|
-
buttonName: "Next",
|
|
64
|
-
},
|
|
65
|
-
name: "Next Image",
|
|
66
|
-
key: "d", //"ArrowRight"
|
|
67
|
-
},
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default ({ onShortcutActionDispatched }) => {
|
|
71
|
-
const [shortcuts, setShortcuts] = useState({}) // useLocalStorage
|
|
72
|
-
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
const newShortcuts = { ...shortcuts }
|
|
75
|
-
for (const actionId of Object.keys(defaultShortcuts)) {
|
|
76
|
-
if (!newShortcuts[actionId]) {
|
|
77
|
-
newShortcuts[actionId] = defaultShortcuts[actionId]
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
setShortcuts(newShortcuts)
|
|
81
|
-
}, [])
|
|
82
|
-
|
|
83
|
-
const onChangeShortcut = (actionId, keyName) => {
|
|
84
|
-
setShortcuts(setIn(shortcuts, [actionId, "key"], keyName))
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
const handleKeyPress = (e) => {
|
|
89
|
-
for (const actionId in shortcuts) {
|
|
90
|
-
const shortcut = shortcuts[actionId]
|
|
91
|
-
if (!shortcut || !shortcut.key) {
|
|
92
|
-
continue
|
|
93
|
-
}
|
|
94
|
-
if (e.key === shortcut.key) {
|
|
95
|
-
onShortcutActionDispatched({
|
|
96
|
-
...shortcut.action,
|
|
97
|
-
selectedTool: actionId,
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
window.addEventListener("keypress", handleKeyPress)
|
|
104
|
-
|
|
105
|
-
return () => {
|
|
106
|
-
window.removeEventListener("keypress", handleKeyPress)
|
|
107
|
-
document.activeElement.blur()
|
|
108
|
-
}
|
|
109
|
-
}, [shortcuts])
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<SidebarBoxContainer title="Shortcuts">
|
|
113
|
-
{Object.keys(shortcuts)
|
|
114
|
-
.map((actionId, index) => {
|
|
115
|
-
if (!shortcuts[actionId]) return null
|
|
116
|
-
return (
|
|
117
|
-
<ShortcutField
|
|
118
|
-
key={actionId}
|
|
119
|
-
actionId={actionId}
|
|
120
|
-
actionName={shortcuts[actionId].name}
|
|
121
|
-
keyName={shortcuts[actionId].key || ""}
|
|
122
|
-
onChangeShortcut={onChangeShortcut}
|
|
123
|
-
/>
|
|
124
|
-
)
|
|
125
|
-
})
|
|
126
|
-
.filter(Boolean)}
|
|
127
|
-
</SidebarBoxContainer>
|
|
128
|
-
)
|
|
129
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from "react"
|
|
2
|
-
import { HotKeys } from "react-hotkeys"
|
|
3
|
-
|
|
4
|
-
export const defaultHotkeys = [
|
|
5
|
-
{
|
|
6
|
-
id: "select_tool",
|
|
7
|
-
description: "Switch to the Select Tool",
|
|
8
|
-
binding: "e",
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
id: "zoom_tool",
|
|
12
|
-
description: "Select the Zoom Tool",
|
|
13
|
-
binding: "z",
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
id: "create_point",
|
|
17
|
-
description: "Create a point",
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
id: "create_bounding_box",
|
|
21
|
-
description: "Create a bounding box",
|
|
22
|
-
binding: "b",
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
id: "pan_tool",
|
|
26
|
-
description: "Select the Pan Tool",
|
|
27
|
-
binding: "m",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
id: "create_polygon",
|
|
31
|
-
description: "Create a Polygon",
|
|
32
|
-
binding: "p",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
id: "create_pixel",
|
|
36
|
-
description: "Create a Pixel Mask",
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: "save_and_previous_sample",
|
|
40
|
-
description: "Save and go to previous sample",
|
|
41
|
-
binding: "ArrowLeft",
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
id: "save_and_next_sample",
|
|
45
|
-
description: "Save and go to next sample",
|
|
46
|
-
binding: "ArrowRight",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
id: "save_and_exit_sample",
|
|
50
|
-
description: "Save and exit current sample",
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
id: "exit_sample",
|
|
54
|
-
description: "Exit sample without saving",
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: "delete_region",
|
|
58
|
-
description: "Delete selected region",
|
|
59
|
-
binding: "d",
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
id: "undo",
|
|
63
|
-
description: "Undo latest change",
|
|
64
|
-
binding: "Ctrl+z",
|
|
65
|
-
},
|
|
66
|
-
]
|
|
67
|
-
export const defaultKeyMap = {}
|
|
68
|
-
for (const { id, binding } of defaultHotkeys) defaultKeyMap[id] = binding
|
|
69
|
-
|
|
70
|
-
export const useDispatchHotkeyHandlers = ({ dispatch }) => {
|
|
71
|
-
const handlers = useMemo(
|
|
72
|
-
() => ({
|
|
73
|
-
select_tool: () => {
|
|
74
|
-
dispatch({
|
|
75
|
-
type: "SELECT_TOOL",
|
|
76
|
-
selectedTool: "select",
|
|
77
|
-
})
|
|
78
|
-
},
|
|
79
|
-
zoom_tool: () => {
|
|
80
|
-
dispatch({
|
|
81
|
-
type: "SELECT_TOOL",
|
|
82
|
-
selectedTool: "zoom",
|
|
83
|
-
})
|
|
84
|
-
},
|
|
85
|
-
create_point: () => {
|
|
86
|
-
dispatch({
|
|
87
|
-
type: "SELECT_TOOL",
|
|
88
|
-
selectedTool: "create-point",
|
|
89
|
-
})
|
|
90
|
-
},
|
|
91
|
-
create_bounding_box: () => {
|
|
92
|
-
dispatch({
|
|
93
|
-
type: "SELECT_TOOL",
|
|
94
|
-
selectedTool: "create-box",
|
|
95
|
-
})
|
|
96
|
-
},
|
|
97
|
-
pan_tool: () => {
|
|
98
|
-
dispatch({
|
|
99
|
-
type: "SELECT_TOOL",
|
|
100
|
-
selectedTool: "pan",
|
|
101
|
-
})
|
|
102
|
-
},
|
|
103
|
-
create_polygon: () => {
|
|
104
|
-
dispatch({
|
|
105
|
-
type: "SELECT_TOOL",
|
|
106
|
-
selectedTool: "create-polygon",
|
|
107
|
-
})
|
|
108
|
-
},
|
|
109
|
-
create_pixel: () => {
|
|
110
|
-
dispatch({
|
|
111
|
-
type: "SELECT_TOOL",
|
|
112
|
-
selectedTool: "create-pixel",
|
|
113
|
-
})
|
|
114
|
-
},
|
|
115
|
-
save_and_previous_sample: () => {
|
|
116
|
-
dispatch({
|
|
117
|
-
type: "HEADER_BUTTON_CLICKED",
|
|
118
|
-
buttonName: "Prev",
|
|
119
|
-
})
|
|
120
|
-
},
|
|
121
|
-
save_and_next_sample: () => {
|
|
122
|
-
dispatch({
|
|
123
|
-
type: "HEADER_BUTTON_CLICKED",
|
|
124
|
-
buttonName: "Next",
|
|
125
|
-
})
|
|
126
|
-
},
|
|
127
|
-
save_and_exit_sample: () => {
|
|
128
|
-
dispatch({
|
|
129
|
-
type: "HEADER_BUTTON_CLICKED",
|
|
130
|
-
buttonName: "Save",
|
|
131
|
-
})
|
|
132
|
-
},
|
|
133
|
-
delete_region: () => {
|
|
134
|
-
dispatch({
|
|
135
|
-
type: "DELETE_SELECTED_REGION",
|
|
136
|
-
})
|
|
137
|
-
},
|
|
138
|
-
undo: () => {
|
|
139
|
-
dispatch({
|
|
140
|
-
type: "RESTORE_HISTORY",
|
|
141
|
-
})
|
|
142
|
-
},
|
|
143
|
-
// TODO
|
|
144
|
-
// exit_sample: () => {
|
|
145
|
-
// dispatch({
|
|
146
|
-
// type: "",
|
|
147
|
-
// })
|
|
148
|
-
// }
|
|
149
|
-
}),
|
|
150
|
-
[dispatch]
|
|
151
|
-
)
|
|
152
|
-
return handlers
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export default ({ children, dispatch }) => {
|
|
156
|
-
const handlers = useDispatchHotkeyHandlers({ dispatch })
|
|
157
|
-
return (
|
|
158
|
-
<HotKeys allowChanges handlers={handlers}>
|
|
159
|
-
{children}
|
|
160
|
-
</HotKeys>
|
|
161
|
-
)
|
|
162
|
-
}
|
package/src/Sidebar/index.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import React from "react"
|
|
4
|
-
import { styled } from "@mui/styles"
|
|
5
|
-
import { createTheme, ThemeProvider } from "@mui/material/styles"
|
|
6
|
-
import TaskDescription from "../TaskDescriptionSidebarBox"
|
|
7
|
-
import ImageSelector from "../ImageSelectorSidebarBox"
|
|
8
|
-
import RegionSelector from "../RegionSelectorSidebarBox"
|
|
9
|
-
import History from "../HistorySidebarBox"
|
|
10
|
-
import DebugBox from "../DebugSidebarBox"
|
|
11
|
-
import TagsSidebarBox from "../TagsSidebarBox"
|
|
12
|
-
import KeyframesSelector from "../KeyframesSelectorSidebarBox"
|
|
13
|
-
import type { Region } from "../ImageCanvas/region-tools.js"
|
|
14
|
-
|
|
15
|
-
const theme = createTheme()
|
|
16
|
-
const Container = styled("div")(({ theme }) => ({}))
|
|
17
|
-
|
|
18
|
-
type Image = {
|
|
19
|
-
name: string,
|
|
20
|
-
src: string,
|
|
21
|
-
cls?: string,
|
|
22
|
-
tags?: Array<string>,
|
|
23
|
-
thumbnailSrc?: string,
|
|
24
|
-
regions?: Array<Region>,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type Props = {
|
|
28
|
-
debug: any,
|
|
29
|
-
taskDescription: string,
|
|
30
|
-
images?: Array<Image>,
|
|
31
|
-
regions: Array<Region>,
|
|
32
|
-
history: Array<{ state: Object, name: string, time: Date }>,
|
|
33
|
-
|
|
34
|
-
labelImages?: boolean,
|
|
35
|
-
currentImage?: Image,
|
|
36
|
-
imageClsList?: Array<string>,
|
|
37
|
-
imageTagList?: Array<string>,
|
|
38
|
-
|
|
39
|
-
onChangeImage: (Image) => any,
|
|
40
|
-
onSelectRegion: (Region) => any,
|
|
41
|
-
onSelectImage: (Image) => any,
|
|
42
|
-
onChangeRegion: (Region) => any,
|
|
43
|
-
onDeleteRegion: (Region) => any,
|
|
44
|
-
onRestoreHistory: () => any,
|
|
45
|
-
onShortcutActionDispatched: (action: any) => any,
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const emptyArr = []
|
|
49
|
-
|
|
50
|
-
export const Sidebar = ({
|
|
51
|
-
debug,
|
|
52
|
-
taskDescription,
|
|
53
|
-
keyframes,
|
|
54
|
-
images,
|
|
55
|
-
regions,
|
|
56
|
-
history,
|
|
57
|
-
labelImages,
|
|
58
|
-
currentImage,
|
|
59
|
-
currentVideoTime,
|
|
60
|
-
imageClsList,
|
|
61
|
-
imageTagList,
|
|
62
|
-
onChangeImage,
|
|
63
|
-
onSelectRegion,
|
|
64
|
-
onSelectImage,
|
|
65
|
-
onChangeRegion,
|
|
66
|
-
onDeleteRegion,
|
|
67
|
-
onRestoreHistory,
|
|
68
|
-
onChangeVideoTime,
|
|
69
|
-
onDeleteKeyframe,
|
|
70
|
-
onShortcutActionDispatched,
|
|
71
|
-
}: Props) => {
|
|
72
|
-
if (!regions) regions = emptyArr
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<ThemeProvider theme={theme}>
|
|
76
|
-
<Container>
|
|
77
|
-
{debug && <DebugBox state={debug} lastAction={debug.lastAction} />}
|
|
78
|
-
{taskDescription && (taskDescription || "").length > 1 && (
|
|
79
|
-
<TaskDescription description={taskDescription} />
|
|
80
|
-
)}
|
|
81
|
-
{labelImages && (
|
|
82
|
-
<TagsSidebarBox
|
|
83
|
-
currentImage={currentImage}
|
|
84
|
-
imageClsList={imageClsList}
|
|
85
|
-
imageTagList={imageTagList}
|
|
86
|
-
onChangeImage={onChangeImage}
|
|
87
|
-
expandedByDefault
|
|
88
|
-
/>
|
|
89
|
-
)}
|
|
90
|
-
{/* {images && images.length > 1 && (
|
|
91
|
-
<ImageSelector onSelect={onSelectImage} images={images} />
|
|
92
|
-
)} */}
|
|
93
|
-
<RegionSelector
|
|
94
|
-
regions={regions}
|
|
95
|
-
onSelectRegion={onSelectRegion}
|
|
96
|
-
onChangeRegion={onChangeRegion}
|
|
97
|
-
onDeleteRegion={onDeleteRegion}
|
|
98
|
-
/>
|
|
99
|
-
{keyframes && (
|
|
100
|
-
<KeyframesSelector
|
|
101
|
-
currentVideoTime={currentVideoTime}
|
|
102
|
-
keyframes={keyframes}
|
|
103
|
-
onChangeVideoTime={onChangeVideoTime}
|
|
104
|
-
onDeleteKeyframe={onDeleteKeyframe}
|
|
105
|
-
/>
|
|
106
|
-
)}
|
|
107
|
-
<History
|
|
108
|
-
history={history}
|
|
109
|
-
onRestoreHistory={() => onRestoreHistory()}
|
|
110
|
-
/>
|
|
111
|
-
{/* <Shortcuts onShortcutActionDispatched={onShortcutActionDispatched} /> */}
|
|
112
|
-
</Container>
|
|
113
|
-
</ThemeProvider>
|
|
114
|
-
)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export default Sidebar
|