react-image-annotate-master-custom 0.0.18 → 0.0.22
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/RegionLabel/index.js +8 -141
- package/RegionLabel/styles.js +2 -2
- package/RegionShapes/index.js +8 -41
- package/RegionTags/index.js +3 -2
- package/package.json +1 -1
package/RegionLabel/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
2
1
|
import React, { useRef, memo } from "react";
|
|
3
2
|
import Paper from "@mui/material/Paper";
|
|
4
3
|
import { makeStyles } from "@mui/styles";
|
|
@@ -23,7 +22,7 @@ export var RegionLabel = function RegionLabel(_ref) {
|
|
|
23
22
|
allowedClasses = _ref.allowedClasses,
|
|
24
23
|
allowedTags = _ref.allowedTags,
|
|
25
24
|
onDelete = _ref.onDelete,
|
|
26
|
-
|
|
25
|
+
onChange = _ref.onChange,
|
|
27
26
|
onClose = _ref.onClose,
|
|
28
27
|
onOpen = _ref.onOpen,
|
|
29
28
|
onRegionClassAdded = _ref.onRegionClassAdded,
|
|
@@ -39,158 +38,26 @@ export var RegionLabel = function RegionLabel(_ref) {
|
|
|
39
38
|
|
|
40
39
|
return React.createElement(ThemeProvider, {
|
|
41
40
|
theme: theme
|
|
42
|
-
}, React.createElement(Paper
|
|
43
|
-
|
|
44
|
-
return !editing ? onOpen(region) : null;
|
|
45
|
-
},
|
|
41
|
+
}, region.cls && React.createElement(Paper // onClick={() => (!editing ? onOpen(region) : null)}
|
|
42
|
+
, {
|
|
46
43
|
className: classnames(classes.regionInfo, {
|
|
47
|
-
highlighted: region.highlighted
|
|
44
|
+
highlighted: true // highlighted: region.highlighted,
|
|
45
|
+
|
|
48
46
|
})
|
|
49
47
|
}, React.createElement("div", {
|
|
50
48
|
style: {
|
|
51
|
-
display: "
|
|
49
|
+
display: "unset"
|
|
52
50
|
}
|
|
53
51
|
}, region.cls && React.createElement("div", {
|
|
54
52
|
className: "name"
|
|
55
|
-
}, React.createElement("div", {
|
|
56
|
-
className: "circle",
|
|
57
|
-
style: {
|
|
58
|
-
backgroundColor: region.color
|
|
59
|
-
}
|
|
60
|
-
}), region.cls), region.tags && React.createElement("div", {
|
|
53
|
+
}, "#".concat(region.cls)), region.tags && React.createElement("div", {
|
|
61
54
|
className: "tags"
|
|
62
55
|
}, region.tags.map(function (t) {
|
|
63
56
|
return React.createElement("div", {
|
|
64
57
|
key: t,
|
|
65
58
|
className: "tag"
|
|
66
59
|
}, t);
|
|
67
|
-
})))
|
|
68
|
-
style: {
|
|
69
|
-
width: 200,
|
|
70
|
-
display: "".concat(editing ? "unset" : "none")
|
|
71
|
-
}
|
|
72
|
-
}, React.createElement("div", {
|
|
73
|
-
style: {
|
|
74
|
-
display: "flex",
|
|
75
|
-
flexDirection: "row"
|
|
76
|
-
}
|
|
77
|
-
}, React.createElement("div", {
|
|
78
|
-
style: {
|
|
79
|
-
display: "flex",
|
|
80
|
-
backgroundColor: region.color || "#888",
|
|
81
|
-
color: "#fff",
|
|
82
|
-
padding: 4,
|
|
83
|
-
paddingLeft: 8,
|
|
84
|
-
paddingRight: 8,
|
|
85
|
-
borderRadius: 4,
|
|
86
|
-
fontWeight: "bold",
|
|
87
|
-
textShadow: "0px 0px 5px rgba(0,0,0,0.4)"
|
|
88
|
-
}
|
|
89
|
-
}, region.type), React.createElement("div", {
|
|
90
|
-
style: {
|
|
91
|
-
flexGrow: 1
|
|
92
|
-
}
|
|
93
|
-
}), React.createElement(IconButton, {
|
|
94
|
-
onClick: function onClick() {
|
|
95
|
-
return onDelete(region);
|
|
96
|
-
},
|
|
97
|
-
tabIndex: -1,
|
|
98
|
-
style: {
|
|
99
|
-
width: 22,
|
|
100
|
-
height: 22
|
|
101
|
-
},
|
|
102
|
-
size: "small",
|
|
103
|
-
variant: "outlined",
|
|
104
|
-
id: "delete-region-".concat(region.id)
|
|
105
|
-
}, React.createElement(TrashIcon, {
|
|
106
|
-
style: {
|
|
107
|
-
marginTop: -8,
|
|
108
|
-
width: 16,
|
|
109
|
-
height: 16
|
|
110
|
-
}
|
|
111
|
-
}))), (allowedClasses || []).length > 0 && React.createElement("div", {
|
|
112
|
-
style: {
|
|
113
|
-
marginTop: 6
|
|
114
|
-
}
|
|
115
|
-
}, React.createElement(CreatableSelect, {
|
|
116
|
-
placeholder: "Classification",
|
|
117
|
-
onChange: function onChange(o, actionMeta) {
|
|
118
|
-
if (actionMeta.action == "create-option") {
|
|
119
|
-
onRegionClassAdded(o.value);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return _onChange(_objectSpread({}, region, {
|
|
123
|
-
cls: o.value
|
|
124
|
-
}));
|
|
125
|
-
},
|
|
126
|
-
value: region.cls ? {
|
|
127
|
-
label: region.cls,
|
|
128
|
-
value: region.cls
|
|
129
|
-
} : null,
|
|
130
|
-
options: asMutable(allowedClasses.map(function (c) {
|
|
131
|
-
return {
|
|
132
|
-
value: c,
|
|
133
|
-
label: c
|
|
134
|
-
};
|
|
135
|
-
}))
|
|
136
|
-
})), (allowedTags || []).length > 0 && React.createElement("div", {
|
|
137
|
-
style: {
|
|
138
|
-
marginTop: 4
|
|
139
|
-
}
|
|
140
|
-
}, React.createElement(Select, {
|
|
141
|
-
onChange: function onChange(newTags) {
|
|
142
|
-
return _onChange(_objectSpread({}, region, {
|
|
143
|
-
tags: newTags.map(function (t) {
|
|
144
|
-
return t.value;
|
|
145
|
-
})
|
|
146
|
-
}));
|
|
147
|
-
},
|
|
148
|
-
placeholder: "Tags",
|
|
149
|
-
value: (region.tags || []).map(function (c) {
|
|
150
|
-
return {
|
|
151
|
-
label: c,
|
|
152
|
-
value: c
|
|
153
|
-
};
|
|
154
|
-
}),
|
|
155
|
-
isMulti: true,
|
|
156
|
-
options: asMutable(allowedTags.map(function (c) {
|
|
157
|
-
return {
|
|
158
|
-
value: c,
|
|
159
|
-
label: c
|
|
160
|
-
};
|
|
161
|
-
}))
|
|
162
|
-
})), allowComments && React.createElement(TextField, {
|
|
163
|
-
InputProps: {
|
|
164
|
-
className: classes.commentBox
|
|
165
|
-
},
|
|
166
|
-
fullWidth: true,
|
|
167
|
-
multiline: true,
|
|
168
|
-
rows: 3,
|
|
169
|
-
ref: commentInputRef,
|
|
170
|
-
onClick: onCommentInputClick,
|
|
171
|
-
value: region.comment || "",
|
|
172
|
-
onChange: function onChange(event) {
|
|
173
|
-
return _onChange(_objectSpread({}, region, {
|
|
174
|
-
comment: event.target.value
|
|
175
|
-
}));
|
|
176
|
-
}
|
|
177
|
-
}), onClose && React.createElement("div", {
|
|
178
|
-
style: {
|
|
179
|
-
marginTop: 4,
|
|
180
|
-
display: "flex"
|
|
181
|
-
}
|
|
182
|
-
}, React.createElement("div", {
|
|
183
|
-
style: {
|
|
184
|
-
flexGrow: 1
|
|
185
|
-
}
|
|
186
|
-
}), React.createElement(Button, {
|
|
187
|
-
onClick: function onClick() {
|
|
188
|
-
return onClose(region);
|
|
189
|
-
},
|
|
190
|
-
size: "small",
|
|
191
|
-
variant: "contained",
|
|
192
|
-
color: "primary"
|
|
193
|
-
}, React.createElement(CheckIcon, null))))));
|
|
60
|
+
})))));
|
|
194
61
|
};
|
|
195
62
|
export default memo(RegionLabel, function (prevProps, nextProps) {
|
|
196
63
|
return prevProps.editing === nextProps.editing && prevProps.region === nextProps.region;
|
package/RegionLabel/styles.js
CHANGED
package/RegionShapes/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React, { memo } from "react";
|
|
3
3
|
import colorAlpha from "color-alpha";
|
|
4
|
-
import "./regionShape.css";
|
|
5
4
|
|
|
6
5
|
function clamp(num, min, max) {
|
|
7
6
|
return num <= min ? min : num >= max ? max : num;
|
|
@@ -13,7 +12,7 @@ var RegionComponents = {
|
|
|
13
12
|
var region = _ref.region,
|
|
14
13
|
iw = _ref.iw,
|
|
15
14
|
ih = _ref.ih;
|
|
16
|
-
return React.createElement(
|
|
15
|
+
return React.createElement("g", {
|
|
17
16
|
transform: "translate(".concat(region.x * iw, " ").concat(region.y * ih, ")")
|
|
18
17
|
}, React.createElement("path", {
|
|
19
18
|
d: "M 1.866 12.7018 C 4.234 9.7951 9.486 2.7501 9.486 -1.207 C 9.486 -6.0063 5.5922 -9.9 0.793 -9.9 S -7.9 -6.0063 -7.9 -1.207 c 0 3.9571 5.2973 11.0021 7.62 13.9088 c 0.5569 0.6927 1.5892 0.6927 2.1461 0 z M 0.793 -4.1047 A 2.8977 2.8977 90 1 1 0.793 1.6907 a 2.8977 2.8977 90 1 1 0 -5.7953 z",
|
|
@@ -24,7 +23,7 @@ var RegionComponents = {
|
|
|
24
23
|
strokeWidth: 2,
|
|
25
24
|
stroke: "#E45B21",
|
|
26
25
|
fill: "#E45B21"
|
|
27
|
-
}))
|
|
26
|
+
}));
|
|
28
27
|
}),
|
|
29
28
|
line: memo(function (_ref2) {
|
|
30
29
|
var region = _ref2.region,
|
|
@@ -246,42 +245,17 @@ export var WrappedRegionList = memo(function (_ref19) {
|
|
|
246
245
|
}, function (n, p) {
|
|
247
246
|
return n.regions === p.regions && n.iw === p.iw && n.ih === p.ih;
|
|
248
247
|
});
|
|
249
|
-
export var
|
|
250
|
-
var
|
|
248
|
+
export var RegionShapes = function RegionShapes(_ref20) {
|
|
249
|
+
var mat = _ref20.mat,
|
|
250
|
+
imagePosition = _ref20.imagePosition,
|
|
251
|
+
_ref20$regions = _ref20.regions,
|
|
252
|
+
regions = _ref20$regions === void 0 ? [] : _ref20$regions,
|
|
251
253
|
keypointDefinitions = _ref20.keypointDefinitions,
|
|
252
|
-
iw = _ref20.iw,
|
|
253
|
-
ih = _ref20.ih,
|
|
254
254
|
fullSegmentationMode = _ref20.fullSegmentationMode;
|
|
255
|
-
return regions.filter(function (r) {
|
|
256
|
-
return r.visible !== false;
|
|
257
|
-
}).map(function (r) {
|
|
258
|
-
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
259
|
-
style: {
|
|
260
|
-
color: '#800020',
|
|
261
|
-
position: 'absolute',
|
|
262
|
-
zIndex: 1000,
|
|
263
|
-
left: r.x * iw + 18,
|
|
264
|
-
top: r.y * ih + 18,
|
|
265
|
-
fontSize: '13px',
|
|
266
|
-
fontWeight: 500
|
|
267
|
-
},
|
|
268
|
-
className: "noselect"
|
|
269
|
-
}, (r === null || r === void 0 ? void 0 : r.sid) && "#".concat(r === null || r === void 0 ? void 0 : r.sid)));
|
|
270
|
-
});
|
|
271
|
-
}, function (n, p) {
|
|
272
|
-
return n.regions === p.regions && n.iw === p.iw && n.ih === p.ih;
|
|
273
|
-
});
|
|
274
|
-
export var RegionShapes = function RegionShapes(_ref21) {
|
|
275
|
-
var mat = _ref21.mat,
|
|
276
|
-
imagePosition = _ref21.imagePosition,
|
|
277
|
-
_ref21$regions = _ref21.regions,
|
|
278
|
-
regions = _ref21$regions === void 0 ? [] : _ref21$regions,
|
|
279
|
-
keypointDefinitions = _ref21.keypointDefinitions,
|
|
280
|
-
fullSegmentationMode = _ref21.fullSegmentationMode;
|
|
281
255
|
var iw = imagePosition.bottomRight.x - imagePosition.topLeft.x;
|
|
282
256
|
var ih = imagePosition.bottomRight.y - imagePosition.topLeft.y;
|
|
283
257
|
if (isNaN(iw) || isNaN(ih)) return null;
|
|
284
|
-
return React.createElement(
|
|
258
|
+
return React.createElement("svg", {
|
|
285
259
|
width: iw,
|
|
286
260
|
height: ih,
|
|
287
261
|
style: {
|
|
@@ -300,13 +274,6 @@ export var RegionShapes = function RegionShapes(_ref21) {
|
|
|
300
274
|
ih: ih,
|
|
301
275
|
keypointDefinitions: keypointDefinitions,
|
|
302
276
|
fullSegmentationMode: fullSegmentationMode
|
|
303
|
-
})), React.createElement(WrappedRegionListSid, {
|
|
304
|
-
key: "wrapped-region-list-sid",
|
|
305
|
-
regions: regions,
|
|
306
|
-
iw: iw,
|
|
307
|
-
ih: ih,
|
|
308
|
-
keypointDefinitions: keypointDefinitions,
|
|
309
|
-
fullSegmentationMode: fullSegmentationMode
|
|
310
277
|
}));
|
|
311
278
|
};
|
|
312
279
|
export default RegionShapes;
|
package/RegionTags/index.js
CHANGED
|
@@ -44,8 +44,9 @@ export var RegionTags = function RegionTags(_ref) {
|
|
|
44
44
|
ih = _layoutParams$current.ih;
|
|
45
45
|
var margin = 8;
|
|
46
46
|
if (region.highlighted && region.type === "box") margin += 6;
|
|
47
|
-
var labelBoxHeight = region.editingLabels && !region.locked ? 300 : region.tags ? 60 : 50;
|
|
48
|
-
|
|
47
|
+
var labelBoxHeight = region.editingLabels && !region.locked ? 300 : region.tags ? 60 : 50; // const displayOnTop = pbox.y > labelBoxHeight
|
|
48
|
+
|
|
49
|
+
var displayOnTop = true;
|
|
49
50
|
var coords = displayOnTop ? {
|
|
50
51
|
left: pbox.x,
|
|
51
52
|
top: pbox.y - margin / 2
|