@glodon-aiot/dataset-annotation 3.15.5-alpha.1 → 3.15.5-alpha.2
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/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +59 -59
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +85 -37
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +201 -139
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +232 -192
- package/dist/es/components/DetectionAnnotation/index.mjs +252 -230
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +26 -26
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +83 -72
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +19 -19
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.mjs +53 -52
- package/dist/es/index.mjs +1 -1
- package/dist/lib/index.js +3 -3
- package/dist/src/components/VLMAnnotation/types.d.ts +1 -0
- package/package.json +2 -2
|
@@ -2,27 +2,27 @@ var _ = Object.defineProperty, $ = Object.defineProperties;
|
|
|
2
2
|
var V = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var M = Object.getOwnPropertySymbols;
|
|
4
4
|
var S = Object.prototype.hasOwnProperty, ee = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var A = (n, t,
|
|
6
|
-
for (var
|
|
7
|
-
S.call(t,
|
|
5
|
+
var A = (n, t, o) => t in n ? _(n, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[t] = o, b = (n, t) => {
|
|
6
|
+
for (var o in t || (t = {}))
|
|
7
|
+
S.call(t, o) && A(n, o, t[o]);
|
|
8
8
|
if (M)
|
|
9
|
-
for (var
|
|
10
|
-
ee.call(t,
|
|
9
|
+
for (var o of M(t))
|
|
10
|
+
ee.call(t, o) && A(n, o, t[o]);
|
|
11
11
|
return n;
|
|
12
12
|
}, u = (n, t) => $(n, V(t));
|
|
13
|
-
import { jsxs as
|
|
13
|
+
import { jsxs as m, jsx as f } from "react/jsx-runtime";
|
|
14
14
|
import { useRef as B, useState as h, useEffect as g } from "react";
|
|
15
15
|
import { Button as H } from "antd";
|
|
16
16
|
import { useKeyPress as K } from "ahooks";
|
|
17
17
|
import "./style.less.mjs";
|
|
18
18
|
import ie from "../Labels/index.mjs";
|
|
19
|
-
import
|
|
19
|
+
import se from "../LabelMaker/index.mjs";
|
|
20
20
|
import O from "../../../Iconfont/index.mjs";
|
|
21
|
-
const
|
|
21
|
+
const be = (n) => {
|
|
22
22
|
var D, E, F;
|
|
23
23
|
const {
|
|
24
24
|
datasetId: t,
|
|
25
|
-
isImageDetailVisible:
|
|
25
|
+
isImageDetailVisible: o = !0,
|
|
26
26
|
currentSample: e,
|
|
27
27
|
onNextClick: v,
|
|
28
28
|
onPrevClick: L,
|
|
@@ -36,8 +36,8 @@ const me = (n) => {
|
|
|
36
36
|
readonly: G,
|
|
37
37
|
showLabelList: P = !0,
|
|
38
38
|
renderLabelItem: J,
|
|
39
|
-
onLoadingChange:
|
|
40
|
-
} = n, Q = B(null), T = B({}), [z, W] = h({}), [
|
|
39
|
+
onLoadingChange: w
|
|
40
|
+
} = n, Q = B(null), T = B({}), [z, W] = h({}), [p, x] = h(), [a, y] = h(), [X, Y] = h(!1), [I, R] = h(!1);
|
|
41
41
|
K("rightarrow", () => {
|
|
42
42
|
v && v();
|
|
43
43
|
}), K("leftarrow", () => {
|
|
@@ -45,115 +45,115 @@ const me = (n) => {
|
|
|
45
45
|
}), g(() => () => {
|
|
46
46
|
X && N && N();
|
|
47
47
|
}, []), g(() => {
|
|
48
|
-
var
|
|
49
|
-
if (
|
|
48
|
+
var s, l;
|
|
49
|
+
if (x(void 0), (e == null ? void 0 : e.id) !== (a == null ? void 0 : a.id) && y(void 0), !o || !((s = e == null ? void 0 : e.labels) != null && s.length))
|
|
50
50
|
return;
|
|
51
|
-
const i = (
|
|
51
|
+
const i = (l = a || e) == null ? void 0 : l.labels.reduce((c, j) => (c[j.id] ? ++c[j.id] : c[j.id] = 1, c), {});
|
|
52
52
|
W(i || {});
|
|
53
|
-
}, [
|
|
53
|
+
}, [o, e, a]), g(() => {
|
|
54
54
|
e != null && e.fileUrl && R(!0);
|
|
55
55
|
}, [e == null ? void 0 : e.fileUrl]), g(() => {
|
|
56
|
-
|
|
57
|
-
}, [
|
|
58
|
-
if (
|
|
56
|
+
w && w(I);
|
|
57
|
+
}, [I, w]), g(() => {
|
|
58
|
+
if (a != null && a.labels) {
|
|
59
59
|
const i = [];
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
label:
|
|
60
|
+
a.labels.forEach((s) => {
|
|
61
|
+
const l = d.find((c) => c.id === s.id);
|
|
62
|
+
l && i.push(u(b({}, s), {
|
|
63
|
+
label: l.label
|
|
64
64
|
}));
|
|
65
|
-
}),
|
|
65
|
+
}), a.labels = i, y(b({}, a));
|
|
66
66
|
}
|
|
67
67
|
}, [d]);
|
|
68
68
|
const Z = () => {
|
|
69
69
|
Q.current && R(!1);
|
|
70
70
|
};
|
|
71
|
-
return window.onresize = Z, /* @__PURE__ */
|
|
71
|
+
return window.onresize = Z, /* @__PURE__ */ m("div", {
|
|
72
72
|
className: "detection-image-detail",
|
|
73
|
-
children: [/* @__PURE__ */
|
|
73
|
+
children: [/* @__PURE__ */ m("div", {
|
|
74
74
|
className: "detail-image",
|
|
75
|
-
children: [U ? /* @__PURE__ */
|
|
75
|
+
children: [U ? /* @__PURE__ */ m("div", {
|
|
76
76
|
className: "img-detail-info",
|
|
77
77
|
children: ["第 ", r == null ? void 0 : r.index, " 张 / 共 ", r == null ? void 0 : r.total, " 张"]
|
|
78
|
-
}) : /* @__PURE__ */
|
|
78
|
+
}) : /* @__PURE__ */ f("div", {
|
|
79
79
|
className: "img-detail-info",
|
|
80
80
|
children: r == null ? void 0 : r.index
|
|
81
|
-
}), /* @__PURE__ */
|
|
81
|
+
}), /* @__PURE__ */ m("div", {
|
|
82
82
|
className: "detail-content",
|
|
83
|
-
children: [L && /* @__PURE__ */
|
|
83
|
+
children: [L && /* @__PURE__ */ f(H, {
|
|
84
84
|
className: "select-prev",
|
|
85
|
-
icon: /* @__PURE__ */
|
|
85
|
+
icon: /* @__PURE__ */ f(O, {
|
|
86
86
|
type: "icon-zuojiantou"
|
|
87
87
|
}),
|
|
88
88
|
type: "text",
|
|
89
|
-
disabled:
|
|
89
|
+
disabled: I,
|
|
90
90
|
onClick: () => L(),
|
|
91
91
|
tabIndex: 0
|
|
92
|
-
}), /* @__PURE__ */
|
|
92
|
+
}), /* @__PURE__ */ m("div", {
|
|
93
93
|
className: "select-main",
|
|
94
94
|
ref: T,
|
|
95
|
-
children: [((D = e == null ? void 0 : e.sampleFileName) == null ? void 0 : D.name) && /* @__PURE__ */
|
|
95
|
+
children: [((D = e == null ? void 0 : e.sampleFileName) == null ? void 0 : D.name) && /* @__PURE__ */ f("div", {
|
|
96
96
|
className: "img-detail-name-overlay",
|
|
97
97
|
children: e.sampleFileName.name
|
|
98
|
-
}), /* @__PURE__ */
|
|
98
|
+
}), /* @__PURE__ */ f(se, {
|
|
99
99
|
disabled: G,
|
|
100
100
|
imageUrl: (e == null ? void 0 : e.fileUrl) || "",
|
|
101
|
-
pen:
|
|
102
|
-
labels: ((E =
|
|
103
|
-
var
|
|
104
|
-
return u(
|
|
105
|
-
color: ((
|
|
101
|
+
pen: p,
|
|
102
|
+
labels: ((E = a ? a.labels : e == null ? void 0 : e.labels) == null ? void 0 : E.map((i) => {
|
|
103
|
+
var s;
|
|
104
|
+
return u(b({}, i), {
|
|
105
|
+
color: ((s = d.find((l) => l.id === i.id)) == null ? void 0 : s.color) || ""
|
|
106
106
|
});
|
|
107
107
|
})) || [],
|
|
108
108
|
onImageLoad: () => R(!1),
|
|
109
109
|
onChange: (i) => {
|
|
110
|
-
if (
|
|
110
|
+
if (x(void 0), !e)
|
|
111
111
|
return;
|
|
112
|
-
const
|
|
113
|
-
labels: i.map((
|
|
114
|
-
id:
|
|
115
|
-
label:
|
|
116
|
-
box:
|
|
112
|
+
const s = u(b({}, e), {
|
|
113
|
+
labels: i.map((l) => ({
|
|
114
|
+
id: l.id,
|
|
115
|
+
label: l.label,
|
|
116
|
+
box: l.box
|
|
117
117
|
}))
|
|
118
118
|
});
|
|
119
|
-
y(
|
|
119
|
+
y(s), k && k(s);
|
|
120
120
|
},
|
|
121
121
|
isPreLabel: C,
|
|
122
122
|
renderLabelItem: J
|
|
123
123
|
}, P ? "with-slide" : "no-slide")]
|
|
124
|
-
}), v && /* @__PURE__ */
|
|
124
|
+
}), v && /* @__PURE__ */ f(H, {
|
|
125
125
|
className: "select-next",
|
|
126
|
-
icon: /* @__PURE__ */
|
|
126
|
+
icon: /* @__PURE__ */ f(O, {
|
|
127
127
|
type: "icon-youjiantou"
|
|
128
128
|
}),
|
|
129
129
|
type: "text",
|
|
130
|
-
disabled:
|
|
130
|
+
disabled: I,
|
|
131
131
|
onClick: () => v()
|
|
132
132
|
})]
|
|
133
133
|
})]
|
|
134
|
-
}), (!!(d != null && d.length) || q) && P && /* @__PURE__ */
|
|
134
|
+
}), (!!(d != null && d.length) || q) && P && /* @__PURE__ */ f("div", {
|
|
135
135
|
className: "detail-slide",
|
|
136
|
-
children: /* @__PURE__ */
|
|
136
|
+
children: /* @__PURE__ */ f(ie, {
|
|
137
137
|
datasetId: t,
|
|
138
138
|
selectMode: "single",
|
|
139
139
|
data: ((F = Object.keys(z)) == null ? void 0 : F.map((i) => {
|
|
140
|
-
const
|
|
141
|
-
if (
|
|
142
|
-
return
|
|
140
|
+
const s = d.find((l) => l.id === i);
|
|
141
|
+
if (s)
|
|
142
|
+
return s.count = z[i], s;
|
|
143
143
|
}).filter((i) => !!i)) || [],
|
|
144
144
|
shortcut: !0,
|
|
145
|
-
selected:
|
|
145
|
+
selected: p ? [p] : [],
|
|
146
146
|
onSelectedChange: (i) => {
|
|
147
147
|
if (i.length > 2) {
|
|
148
148
|
console.warn("不支持选中多个标签");
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
if (!i.length) {
|
|
152
|
-
|
|
152
|
+
x(void 0);
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
|
-
const
|
|
156
|
-
|
|
155
|
+
const s = d == null ? void 0 : d.find((l) => i[0].label === l.label);
|
|
156
|
+
x(s);
|
|
157
157
|
},
|
|
158
158
|
onListChange: () => {
|
|
159
159
|
Y(!0), N && N();
|
|
@@ -165,5 +165,5 @@ const me = (n) => {
|
|
|
165
165
|
});
|
|
166
166
|
};
|
|
167
167
|
export {
|
|
168
|
-
|
|
168
|
+
be as default
|
|
169
169
|
};
|
|
@@ -1,54 +1,102 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
function A(t, w) {
|
|
2
|
+
I(t);
|
|
3
|
+
let s = -1, p = -1, b = 0, T = 0, x = !1;
|
|
4
|
+
t.on("mouse:down:before", (l) => {
|
|
5
|
+
const i = l.target, n = t.getActiveObject(), g = t.getPointer(l.e), c = t.backgroundImage, m = c == null ? void 0 : c.aCoords;
|
|
6
|
+
let o = !1;
|
|
7
|
+
if (m && (o = g.x >= m.tl.x && g.x <= m.br.x && g.y >= m.tl.y && g.y <= m.br.y), !o) {
|
|
8
|
+
n && (t.discardActiveObject(), t.renderAll()), t.skipTargetFind = !0;
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!e.skipTargetFind)
|
|
11
|
+
if (i && i !== t.backgroundImage) {
|
|
12
|
+
n !== i && (t.setActiveObject(i), t.requestRenderAll()), t.skipTargetFind = !1;
|
|
13
13
|
return;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
}
|
|
15
|
+
n && (t.discardActiveObject(), t.renderAll()), t.skipTargetFind = !0;
|
|
16
|
+
}), t.on("mouse:down", (l) => {
|
|
17
|
+
if (!t.skipTargetFind)
|
|
18
|
+
return;
|
|
19
|
+
x = !0, s = -1, p = -1, b = 0, T = 0;
|
|
20
|
+
const i = t.getZoom();
|
|
21
|
+
p = l.e.offsetX / i, s = l.e.offsetY / i;
|
|
22
|
+
}), t.on("mouse:up:before", (l) => {
|
|
23
|
+
if (x) {
|
|
24
|
+
const i = t.selection;
|
|
25
|
+
t.selection = !1, setTimeout(() => {
|
|
26
|
+
t.selection = i;
|
|
27
|
+
}, 0);
|
|
28
|
+
}
|
|
29
|
+
}), t.on("mouse:up", (l) => {
|
|
30
|
+
if (!x) {
|
|
31
|
+
t.skipTargetFind && setTimeout(() => {
|
|
32
|
+
t.skipTargetFind = !1;
|
|
33
|
+
}, 0);
|
|
19
34
|
return;
|
|
20
|
-
|
|
21
|
-
if (
|
|
35
|
+
}
|
|
36
|
+
if (x = !1, p === -1 && s === -1) {
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
t.skipTargetFind = !1;
|
|
39
|
+
}, 0);
|
|
22
40
|
return;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
41
|
+
}
|
|
42
|
+
const i = t.getZoom(), n = l.e.offsetX > t.getWidth() ? t.getWidth() / i : l.e.offsetX / i, g = l.e.offsetY > t.getHeight() ? t.getHeight() / i : l.e.offsetY / i;
|
|
43
|
+
if (b = Math.abs(n - p), T = Math.abs(g - s), b === 0 || T === 0) {
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
t.skipTargetFind = !1;
|
|
46
|
+
}, 0);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const c = t.viewportTransform ? t.viewportTransform[4] / i : 0, m = t.viewportTransform ? t.viewportTransform[5] / i : 0;
|
|
50
|
+
let o = s > g ? g : s, r = p > n ? n : p, d = b, h = T;
|
|
51
|
+
o = o - m, r = r - c;
|
|
26
52
|
const F = () => {
|
|
27
|
-
var
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
53
|
+
var f, k;
|
|
54
|
+
const e = t.backgroundImage;
|
|
55
|
+
if (e && typeof e != "string" && ((f = e.aCoords) != null && f.tl.x, (k = e.aCoords) != null && k.tl.y), e && typeof e != "string" && e.top !== void 0 && e.height !== void 0 && e.left !== void 0 && e.width !== void 0) {
|
|
56
|
+
if (o < e.top) {
|
|
57
|
+
const u = e.top - o;
|
|
58
|
+
h = Math.max(0, h - u), o = e.top;
|
|
59
|
+
}
|
|
60
|
+
if (o + h > e.top + e.height) {
|
|
61
|
+
const u = e.top + e.height - o;
|
|
62
|
+
h = Math.max(0, Math.min(h, u)), o + h > e.top + e.height && (o = e.top + e.height - h);
|
|
63
|
+
}
|
|
64
|
+
if (r < e.left) {
|
|
65
|
+
const u = e.left - r;
|
|
66
|
+
d = Math.max(0, d - u), r = e.left;
|
|
67
|
+
}
|
|
68
|
+
if (r + d > e.left + e.width) {
|
|
69
|
+
const u = e.left + e.width - r;
|
|
70
|
+
d = Math.max(0, Math.min(d, u)), r + d > e.left + e.width && (r = e.left + e.width - d);
|
|
71
|
+
}
|
|
72
|
+
o = Math.max(e.top, Math.min(o, e.top + e.height)), r = Math.max(e.left, Math.min(r, e.left + e.width)), d = Math.max(0, Math.min(d, e.left + e.width - r)), h = Math.max(0, Math.min(h, e.top + e.height - o));
|
|
73
|
+
}
|
|
74
|
+
}, y = (e) => {
|
|
75
|
+
const f = t.backgroundImage;
|
|
76
|
+
return !(f && typeof f != "string" && f.top !== void 0 && f.height !== void 0 && f.left !== void 0 && f.width !== void 0 && (e[0] < f.left - 0.01 || e[1] < f.top - 0.01 || e[0] > f.left + f.width + 0.01 || e[1] > f.top + f.height + 0.01));
|
|
33
77
|
};
|
|
34
78
|
F();
|
|
35
|
-
const
|
|
36
|
-
|
|
79
|
+
const M = [[r, o], [r + d, o], [r + d, o + h], [r, o + h]];
|
|
80
|
+
w && M.every((e) => y(e)) ? (w({
|
|
37
81
|
id: "",
|
|
38
82
|
color: "#cccccc",
|
|
39
83
|
label: "未知",
|
|
40
|
-
box:
|
|
41
|
-
}),
|
|
84
|
+
box: M
|
|
85
|
+
}), setTimeout(() => {
|
|
86
|
+
t.skipTargetFind = !1;
|
|
87
|
+
}, 0)) : (t.discardActiveObject(), t.renderAll(), setTimeout(() => {
|
|
88
|
+
t.skipTargetFind = !1;
|
|
89
|
+
}, 0));
|
|
42
90
|
});
|
|
43
91
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
92
|
+
const I = (t) => {
|
|
93
|
+
t.off("mouse:down"), t.off("mouse:down:before"), t.off("mouse:up"), t.skipTargetFind = !1;
|
|
46
94
|
};
|
|
47
|
-
function
|
|
48
|
-
if (!
|
|
49
|
-
return
|
|
95
|
+
function O(t, w, s) {
|
|
96
|
+
if (!s)
|
|
97
|
+
return A(t, w), t;
|
|
50
98
|
}
|
|
51
99
|
export {
|
|
52
|
-
|
|
53
|
-
|
|
100
|
+
O as drawable,
|
|
101
|
+
I as stopDraw
|
|
54
102
|
};
|