luo-image-annotator 0.0.11 → 0.0.13
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/README.md +35 -0
- package/dist/luo-image-annotator.css +1 -1
- package/dist/luo-image-annotator.es.js +571 -558
- package/dist/luo-image-annotator.umd.js +17 -17
- package/package.json +1 -1
- package//347/273/204/344/273/266/346/216/245/345/205/245/344/270/216/345/271/263/345/217/260/345/210/206/345/261/202/350/257/264/346/230/216.md +19 -2
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
var Jt = Object.defineProperty;
|
|
2
|
-
var jt = (
|
|
3
|
-
var
|
|
4
|
-
import { defineComponent as
|
|
5
|
-
const ct = (
|
|
2
|
+
var jt = (f, t, i) => t in f ? Jt(f, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : f[t] = i;
|
|
3
|
+
var S = (f, t, i) => jt(f, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
import { defineComponent as tt, ref as M, watchEffect as Yt, openBlock as y, createElementBlock as x, normalizeClass as J, computed as D, onMounted as Xt, watch as Y, createElementVNode as g, toDisplayString as P, Fragment as B, renderList as F, normalizeStyle as V, createCommentVNode as T, createVNode as L, withModifiers as qt, createTextVNode as K, withDirectives as lt, vModelText as rt, createBlock as yt, nextTick as Gt } from "vue";
|
|
5
|
+
const ct = (f, t) => Math.sqrt(Math.pow(f.x - t.x, 2) + Math.pow(f.y - t.y, 2)), Kt = (f, t) => {
|
|
6
6
|
let i = !1;
|
|
7
|
-
for (let e = 0,
|
|
8
|
-
const
|
|
9
|
-
|
|
7
|
+
for (let e = 0, o = t.length - 1; e < t.length; o = e++) {
|
|
8
|
+
const c = t[e].x, r = t[e].y, a = t[o].x, d = t[o].y;
|
|
9
|
+
r > f.y != d > f.y && f.x < (a - c) * (f.y - r) / (d - r) + c && (i = !i);
|
|
10
10
|
}
|
|
11
11
|
return i;
|
|
12
|
-
},
|
|
13
|
-
const e = i * (Math.PI / 180),
|
|
12
|
+
}, pt = (f, t, i) => {
|
|
13
|
+
const e = i * (Math.PI / 180), o = Math.cos(e), c = Math.sin(e), r = f.x - t.x, a = f.y - t.y;
|
|
14
14
|
return {
|
|
15
|
-
x: t.x + (
|
|
16
|
-
y: t.y + (
|
|
15
|
+
x: t.x + (r * o - a * c),
|
|
16
|
+
y: t.y + (r * c + a * o)
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
class Zt {
|
|
20
20
|
constructor(t) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
S(this, "canvas");
|
|
22
|
+
S(this, "ctx");
|
|
23
|
+
S(this, "img");
|
|
24
|
+
S(this, "annotations", []);
|
|
25
25
|
// 状态
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
S(this, "currentTool", null);
|
|
27
|
+
S(this, "interactionMode", "none");
|
|
28
|
+
S(this, "activeAnnotation", null);
|
|
29
|
+
S(this, "hoverAnnotation", null);
|
|
30
|
+
S(this, "isDrawing", !1);
|
|
31
|
+
S(this, "isDragging", !1);
|
|
32
|
+
S(this, "isPanning", !1);
|
|
33
33
|
// 平移模式
|
|
34
|
-
|
|
34
|
+
S(this, "panStartPoint", null);
|
|
35
35
|
// 平移起点
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
S(this, "dragStartPoint", null);
|
|
37
|
+
S(this, "dragStartAnnotation", null);
|
|
38
38
|
// 快照用于撤销/diff
|
|
39
|
-
|
|
39
|
+
S(this, "lastMouseMovePoint", null);
|
|
40
40
|
// 用于绘制辅助线
|
|
41
|
-
|
|
41
|
+
S(this, "isHoveringStartPoint", !1);
|
|
42
42
|
// 多边形闭合吸附状态
|
|
43
43
|
// 设置
|
|
44
|
-
|
|
44
|
+
S(this, "currentLabelColor", "#FF4081");
|
|
45
45
|
// 当前选中标签颜色
|
|
46
|
-
|
|
46
|
+
S(this, "visibleLabels", /* @__PURE__ */ new Set());
|
|
47
47
|
// 可见标签集合 (如果为空则全部可见,或者由外部控制渲染列表)
|
|
48
48
|
// 交互
|
|
49
|
-
|
|
49
|
+
S(this, "selectedHandleIndex", -1);
|
|
50
50
|
// -1: 主体, >=0: 顶点索引, -2: 旋转手柄
|
|
51
|
-
|
|
51
|
+
S(this, "hoverHandleIndex", -1);
|
|
52
52
|
// 视口
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
S(this, "scale", 1);
|
|
54
|
+
S(this, "offset", { x: 0, y: 0 });
|
|
55
|
+
S(this, "listeners", {});
|
|
56
|
+
S(this, "imageUrl", "");
|
|
57
57
|
this.canvas = t;
|
|
58
58
|
const i = t.getContext("2d");
|
|
59
59
|
if (!i) throw new Error("Could not get 2d context");
|
|
@@ -89,8 +89,8 @@ class Zt {
|
|
|
89
89
|
zoom(t) {
|
|
90
90
|
const e = t > 0 ? this.scale * 1.1 : this.scale / 1.1;
|
|
91
91
|
if (e < 0.1 || e > 10) return;
|
|
92
|
-
const
|
|
93
|
-
this.scale = e, this.offset.x =
|
|
92
|
+
const o = this.canvas.width / 2, c = this.canvas.height / 2, r = this.toImageCoords(o, c);
|
|
93
|
+
this.scale = e, this.offset.x = o - r.x * this.scale, this.offset.y = c - r.y * this.scale, this.clampViewportOffset(), this.render();
|
|
94
94
|
}
|
|
95
95
|
resize() {
|
|
96
96
|
this.fitImageToCanvas(), this.render();
|
|
@@ -122,14 +122,14 @@ class Zt {
|
|
|
122
122
|
if (t <= this.canvas.width)
|
|
123
123
|
this.offset.x = (this.canvas.width - t) / 2;
|
|
124
124
|
else {
|
|
125
|
-
const e = this.canvas.width - t,
|
|
126
|
-
this.offset.x = Math.min(
|
|
125
|
+
const e = this.canvas.width - t, o = 0;
|
|
126
|
+
this.offset.x = Math.min(o, Math.max(e, this.offset.x));
|
|
127
127
|
}
|
|
128
128
|
if (i <= this.canvas.height)
|
|
129
129
|
this.offset.y = (this.canvas.height - i) / 2;
|
|
130
130
|
else {
|
|
131
|
-
const e = this.canvas.height - i,
|
|
132
|
-
this.offset.y = Math.min(
|
|
131
|
+
const e = this.canvas.height - i, o = 0;
|
|
132
|
+
this.offset.y = Math.min(o, Math.max(e, this.offset.y));
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
// --- 事件处理 ---
|
|
@@ -151,28 +151,28 @@ class Zt {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
handleMouseDown(t) {
|
|
154
|
-
const i = this.canvas.getBoundingClientRect(), e = t.clientX - i.left,
|
|
154
|
+
const i = this.canvas.getBoundingClientRect(), e = t.clientX - i.left, o = t.clientY - i.top, c = this.toImageCoords(e, o);
|
|
155
155
|
if (this.canvas.style.cursor === "grab" || this.canvas.style.cursor === "grabbing") {
|
|
156
|
-
this.isPanning = !0, this.panStartPoint = { x: e, y:
|
|
156
|
+
this.isPanning = !0, this.panStartPoint = { x: e, y: o }, this.canvas.style.cursor = "grabbing";
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
159
|
if (this.interactionMode === "select" && this.activeAnnotation) {
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
this.isDragging = !0, this.dragStartPoint =
|
|
160
|
+
const d = this.getHitHandle(e, o, this.activeAnnotation);
|
|
161
|
+
if (d !== -100) {
|
|
162
|
+
this.isDragging = !0, this.dragStartPoint = c, this.selectedHandleIndex = d, this.dragStartAnnotation = JSON.parse(JSON.stringify(this.activeAnnotation));
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
this.activeAnnotation =
|
|
166
|
+
const r = this.interactionMode === "select" ? this.getHitCategory(e, o) : null;
|
|
167
|
+
if (r) {
|
|
168
|
+
this.activeAnnotation = r, this.isDragging = !1, this.selectedHandleIndex = -1, this.emit("annotationChange", { action: "select", changedItem: r, imageUrl: this.imageUrl }), this.render();
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
|
-
const
|
|
171
|
+
const a = this.getHitAnnotation(c);
|
|
172
172
|
if (this.interactionMode === "select") {
|
|
173
|
-
if (
|
|
174
|
-
if (!(this.visibleLabels.size > 0 && !this.visibleLabels.has(
|
|
175
|
-
this.activeAnnotation =
|
|
173
|
+
if (a) {
|
|
174
|
+
if (!(this.visibleLabels.size > 0 && !this.visibleLabels.has(a.label))) {
|
|
175
|
+
this.activeAnnotation = a, this.isDragging = !0, this.dragStartPoint = c, this.selectedHandleIndex = -1, this.dragStartAnnotation = JSON.parse(JSON.stringify(a)), this.emit("annotationChange", { action: "select", changedItem: a, imageUrl: this.imageUrl }), this.render();
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
178
|
} else
|
|
@@ -181,43 +181,43 @@ class Zt {
|
|
|
181
181
|
}
|
|
182
182
|
if (this.interactionMode === "draw") {
|
|
183
183
|
if (this.isDrawing && this.currentTool === "polygon" && this.activeAnnotation) {
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
184
|
+
const d = this.activeAnnotation.coordinates;
|
|
185
|
+
if (d.points.length > 2 && ct(c, d.points[0]) < 20 / this.scale) {
|
|
186
186
|
this.finishDrawing();
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
|
-
this.startDrawing(
|
|
189
|
+
this.startDrawing(c);
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
if (this.currentTool) {
|
|
193
193
|
if (this.currentTool === "polygon" && !this.isDrawing) {
|
|
194
|
-
this.startDrawing(
|
|
194
|
+
this.startDrawing(c);
|
|
195
195
|
return;
|
|
196
196
|
}
|
|
197
|
-
this.startDrawing(
|
|
197
|
+
this.startDrawing(c);
|
|
198
198
|
}
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
201
|
this.activeAnnotation = null, this.render();
|
|
202
202
|
}
|
|
203
203
|
handleMouseMove(t) {
|
|
204
|
-
const i = this.canvas.getBoundingClientRect(), e = t.clientX - i.left,
|
|
204
|
+
const i = this.canvas.getBoundingClientRect(), e = t.clientX - i.left, o = t.clientY - i.top, c = this.toImageCoords(e, o);
|
|
205
205
|
if (this.isPanning && this.panStartPoint) {
|
|
206
|
-
const
|
|
207
|
-
this.offset.x +=
|
|
206
|
+
const r = e - this.panStartPoint.x, a = o - this.panStartPoint.y;
|
|
207
|
+
this.offset.x += r, this.offset.y += a, this.clampViewportOffset(), this.panStartPoint = { x: e, y: o }, this.render();
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
|
-
if (this.lastMouseMovePoint =
|
|
210
|
+
if (this.lastMouseMovePoint = c, this.isDrawing) {
|
|
211
211
|
if (this.currentTool === "polygon" && this.activeAnnotation) {
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
214
|
-
const
|
|
215
|
-
this.isHoveringStartPoint =
|
|
212
|
+
const r = this.activeAnnotation.coordinates;
|
|
213
|
+
if (r.points.length > 2) {
|
|
214
|
+
const a = r.points[0], d = ct(c, a);
|
|
215
|
+
this.isHoveringStartPoint = d < 20 / this.scale;
|
|
216
216
|
} else
|
|
217
217
|
this.isHoveringStartPoint = !1;
|
|
218
218
|
}
|
|
219
|
-
this.updateDrawing(
|
|
220
|
-
} else this.isDragging && this.activeAnnotation && this.dragStartPoint ? this.updateDragging(
|
|
219
|
+
this.updateDrawing(c);
|
|
220
|
+
} else this.isDragging && this.activeAnnotation && this.dragStartPoint ? this.updateDragging(c) : this.checkHover(e, o, c);
|
|
221
221
|
this.render();
|
|
222
222
|
}
|
|
223
223
|
handleMouseUp(t) {
|
|
@@ -242,8 +242,8 @@ class Zt {
|
|
|
242
242
|
// 辅助函数:将 hex 转换为 rgba
|
|
243
243
|
hexToRgba(t, i) {
|
|
244
244
|
if (!t.startsWith("#")) return t;
|
|
245
|
-
const e = parseInt(t.slice(1, 3), 16),
|
|
246
|
-
return `rgba(${e}, ${
|
|
245
|
+
const e = parseInt(t.slice(1, 3), 16), o = parseInt(t.slice(3, 5), 16), c = parseInt(t.slice(5, 7), 16);
|
|
246
|
+
return `rgba(${e}, ${o}, ${c}, ${i})`;
|
|
247
247
|
}
|
|
248
248
|
startDrawing(t) {
|
|
249
249
|
if (!this.currentTool) return;
|
|
@@ -299,8 +299,8 @@ class Zt {
|
|
|
299
299
|
const i = this.activeAnnotation.coordinates;
|
|
300
300
|
i.x2 = t.x, i.y2 = t.y;
|
|
301
301
|
} else if (this.activeAnnotation.type === "rotatedRect" && this.dragStartPoint) {
|
|
302
|
-
const i = this.activeAnnotation.coordinates, e = Math.abs(t.x - this.dragStartPoint.x),
|
|
303
|
-
i.width = e * 2, i.height =
|
|
302
|
+
const i = this.activeAnnotation.coordinates, e = Math.abs(t.x - this.dragStartPoint.x), o = Math.abs(t.y - this.dragStartPoint.y);
|
|
303
|
+
i.width = e * 2, i.height = o * 2;
|
|
304
304
|
} else this.activeAnnotation.type;
|
|
305
305
|
}
|
|
306
306
|
finishDrawing() {
|
|
@@ -311,8 +311,8 @@ class Zt {
|
|
|
311
311
|
this.activeAnnotation = null, this.isDrawing = !1;
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
|
-
const i = Math.min(t.x1, t.x2), e = Math.max(t.x1, t.x2),
|
|
315
|
-
t.x1 = i, t.x2 = e, t.y1 =
|
|
314
|
+
const i = Math.min(t.x1, t.x2), e = Math.max(t.x1, t.x2), o = Math.min(t.y1, t.y2), c = Math.max(t.y1, t.y2);
|
|
315
|
+
t.x1 = i, t.x2 = e, t.y1 = o, t.y2 = c, this.annotations.push(this.activeAnnotation), this.emit("annotationChange", { action: "add", changedItem: this.activeAnnotation, imageUrl: this.imageUrl });
|
|
316
316
|
} else if (this.activeAnnotation.type === "polygon") {
|
|
317
317
|
if (this.activeAnnotation.coordinates.points.length < 3) {
|
|
318
318
|
this.activeAnnotation = null, this.isDrawing = !1;
|
|
@@ -336,40 +336,40 @@ class Zt {
|
|
|
336
336
|
const i = t.x - this.dragStartPoint.x, e = t.y - this.dragStartPoint.y;
|
|
337
337
|
this.selectedHandleIndex === -1 ? this.moveAnnotation(this.activeAnnotation, this.dragStartAnnotation, i, e) : this.resizeAnnotation(this.activeAnnotation, this.dragStartAnnotation, this.selectedHandleIndex, t);
|
|
338
338
|
}
|
|
339
|
-
moveAnnotation(t, i, e,
|
|
339
|
+
moveAnnotation(t, i, e, o) {
|
|
340
340
|
if (t.type === "rectangle") {
|
|
341
|
-
const
|
|
342
|
-
|
|
341
|
+
const c = i.coordinates, r = t.coordinates;
|
|
342
|
+
r.x1 = c.x1 + e, r.x2 = c.x2 + e, r.y1 = c.y1 + o, r.y2 = c.y2 + o;
|
|
343
343
|
} else if (t.type === "point") {
|
|
344
|
-
const
|
|
345
|
-
|
|
344
|
+
const c = i.coordinates, r = t.coordinates;
|
|
345
|
+
r.points = c.points.map((a) => ({ x: a.x + e, y: a.y + o }));
|
|
346
346
|
} else if (t.type === "rotatedRect") {
|
|
347
|
-
const
|
|
348
|
-
|
|
347
|
+
const c = i.coordinates, r = t.coordinates;
|
|
348
|
+
r.x = c.x + e, r.y = c.y + o;
|
|
349
349
|
} else if (t.type === "polygon") {
|
|
350
|
-
const
|
|
351
|
-
|
|
350
|
+
const c = i.coordinates, r = t.coordinates;
|
|
351
|
+
r.points = c.points.map((a) => ({ x: a.x + e, y: a.y + o }));
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
-
resizeAnnotation(t, i, e,
|
|
354
|
+
resizeAnnotation(t, i, e, o) {
|
|
355
355
|
if (t.type === "rectangle") {
|
|
356
|
-
const
|
|
357
|
-
e === 0 && (
|
|
356
|
+
const c = t.coordinates;
|
|
357
|
+
e === 0 && (c.x1 = o.x, c.y1 = o.y), e === 1 && (c.x2 = o.x, c.y1 = o.y), e === 2 && (c.x2 = o.x, c.y2 = o.y), e === 3 && (c.x1 = o.x, c.y2 = o.y);
|
|
358
358
|
} else if (t.type === "polygon") {
|
|
359
|
-
const
|
|
360
|
-
e >= 0 && e <
|
|
359
|
+
const c = t.coordinates;
|
|
360
|
+
e >= 0 && e < c.points.length && (c.points[e] = o);
|
|
361
361
|
} else if (t.type === "point") {
|
|
362
|
-
const
|
|
363
|
-
e >= 0 && e <
|
|
362
|
+
const c = t.coordinates;
|
|
363
|
+
e >= 0 && e < c.points.length && (c.points[e] = o);
|
|
364
364
|
} else if (t.type === "rotatedRect") {
|
|
365
|
-
const
|
|
365
|
+
const c = t.coordinates;
|
|
366
366
|
if (e === -2) {
|
|
367
|
-
const
|
|
368
|
-
let
|
|
369
|
-
|
|
367
|
+
const r = c.x, a = c.y, d = o.x - r, u = o.y - a;
|
|
368
|
+
let w = Math.atan2(u, d) * 180 / Math.PI;
|
|
369
|
+
w += 90, c.angle = w;
|
|
370
370
|
} else {
|
|
371
|
-
const
|
|
372
|
-
(e === 0 || e === 3) && (
|
|
371
|
+
const r = c.angle * Math.PI / 180, a = Math.cos(-r), d = Math.sin(-r), u = o.x - c.x, w = o.y - c.y, m = u * a - w * d, _ = u * d + w * a;
|
|
372
|
+
(e === 0 || e === 3) && (c.width / 2, c.width = Math.abs(m) * 2), (e === 1 || e === 2) && (c.width = Math.abs(m) * 2), (e === 0 || e === 1) && (c.height = Math.abs(_) * 2), (e === 2 || e === 3) && (c.height = Math.abs(_) * 2);
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
}
|
|
@@ -390,18 +390,18 @@ class Zt {
|
|
|
390
390
|
const e = i.coordinates;
|
|
391
391
|
return Kt(t, e.points);
|
|
392
392
|
} else if (i.type === "rotatedRect") {
|
|
393
|
-
const e = i.coordinates,
|
|
394
|
-
return
|
|
393
|
+
const e = i.coordinates, o = pt(t, { x: e.x, y: e.y }, -e.angle), c = e.width / 2, r = e.height / 2;
|
|
394
|
+
return o.x >= e.x - c && o.x <= e.x + c && o.y >= e.y - r && o.y <= e.y + r;
|
|
395
395
|
} else if (i.type === "point")
|
|
396
|
-
return i.coordinates.points.some((
|
|
396
|
+
return i.coordinates.points.some((o) => ct(t, o) < 10 / this.scale);
|
|
397
397
|
return !1;
|
|
398
398
|
}
|
|
399
399
|
getHitHandle(t, i, e) {
|
|
400
|
-
const
|
|
401
|
-
for (let
|
|
402
|
-
const
|
|
403
|
-
if (Math.abs(t -
|
|
404
|
-
return e.type === "rotatedRect" &&
|
|
400
|
+
const o = this.getAnnotationHandles(e), c = 6;
|
|
401
|
+
for (let r = 0; r < o.length; r++) {
|
|
402
|
+
const a = o[r], d = this.toScreenCoords(a.x, a.y);
|
|
403
|
+
if (Math.abs(t - d.x) < c && Math.abs(i - d.y) < c)
|
|
404
|
+
return e.type === "rotatedRect" && r === 4 ? -2 : r;
|
|
405
405
|
}
|
|
406
406
|
return -100;
|
|
407
407
|
}
|
|
@@ -424,24 +424,24 @@ class Zt {
|
|
|
424
424
|
if (t.type === "point")
|
|
425
425
|
return t.coordinates.points;
|
|
426
426
|
if (t.type === "rotatedRect") {
|
|
427
|
-
const i = t.coordinates, e = { x: i.x, y: i.y },
|
|
428
|
-
return [
|
|
427
|
+
const i = t.coordinates, e = { x: i.x, y: i.y }, o = i.width / 2, c = i.height / 2, r = { x: i.x - o, y: i.y - c }, a = { x: i.x + o, y: i.y - c }, d = { x: i.x + o, y: i.y + c }, u = { x: i.x - o, y: i.y + c }, w = { x: i.x, y: i.y - c - 20 / this.scale };
|
|
428
|
+
return [r, a, d, u, w].map((m) => pt(m, e, i.angle));
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
return [];
|
|
432
432
|
}
|
|
433
433
|
checkHover(t, i, e) {
|
|
434
|
-
const
|
|
435
|
-
if (
|
|
436
|
-
this.canvas.style.cursor = "pointer", this.hoverAnnotation =
|
|
434
|
+
const o = this.getHitCategory(t, i);
|
|
435
|
+
if (o) {
|
|
436
|
+
this.canvas.style.cursor = "pointer", this.hoverAnnotation = o;
|
|
437
437
|
return;
|
|
438
438
|
}
|
|
439
439
|
if (this.activeAnnotation && this.getHitHandle(t, i, this.activeAnnotation) !== -100) {
|
|
440
440
|
this.canvas.style.cursor = "pointer";
|
|
441
441
|
return;
|
|
442
442
|
}
|
|
443
|
-
const
|
|
444
|
-
|
|
443
|
+
const c = this.getHitAnnotation(e);
|
|
444
|
+
c ? (this.canvas.style.cursor = "move", this.hoverAnnotation = c) : (this.canvas.style.cursor = "default", this.hoverAnnotation = null);
|
|
445
445
|
}
|
|
446
446
|
render() {
|
|
447
447
|
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.img.complete && this.img.width > 0 && this.ctx.drawImage(this.img, this.offset.x, this.offset.y, this.img.width * this.scale, this.img.height * this.scale), this.annotations.forEach((t) => {
|
|
@@ -449,76 +449,76 @@ class Zt {
|
|
|
449
449
|
}), this.activeAnnotation && this.drawItem(this.activeAnnotation, !0), this.renderCategories();
|
|
450
450
|
}
|
|
451
451
|
renderCategories() {
|
|
452
|
-
const t = this.annotations.filter((
|
|
452
|
+
const t = this.annotations.filter((d) => d.type === "category");
|
|
453
453
|
if (t.length === 0) return;
|
|
454
454
|
this.ctx.save(), this.ctx.font = "14px sans-serif", this.ctx.textBaseline = "top";
|
|
455
455
|
let i = 10;
|
|
456
|
-
const e = 10,
|
|
457
|
-
t.forEach((
|
|
458
|
-
const u =
|
|
459
|
-
this.ctx.fillStyle =
|
|
456
|
+
const e = 10, o = 8, c = 4, r = 24, a = 8;
|
|
457
|
+
t.forEach((d) => {
|
|
458
|
+
const u = d.label || "Unlabeled", w = this.ctx.measureText(u).width + o * 2, m = this.activeAnnotation === d, _ = this.hoverAnnotation === d;
|
|
459
|
+
this.ctx.fillStyle = m ? "#E3F2FD" : _ ? "#F5F5F5" : "rgba(255, 255, 255, 0.9)", this.ctx.strokeStyle = m ? "#2196F3" : "#666", this.ctx.lineWidth = m ? 2 : 1, this.ctx.beginPath(), this.ctx.rect(i, e, w, r), this.ctx.fill(), this.ctx.stroke(), this.ctx.fillStyle = m ? "#1976D2" : "#333", this.ctx.fillText(u, i + o, e + c), i += w + a;
|
|
460
460
|
}), this.ctx.restore();
|
|
461
461
|
}
|
|
462
462
|
getHitCategory(t, i) {
|
|
463
|
-
const e = this.annotations.filter((
|
|
463
|
+
const e = this.annotations.filter((w) => w.type === "category");
|
|
464
464
|
if (e.length === 0) return null;
|
|
465
465
|
this.ctx.save(), this.ctx.font = "14px sans-serif";
|
|
466
|
-
let
|
|
467
|
-
const
|
|
466
|
+
let o = 10;
|
|
467
|
+
const c = 10, r = 8, a = 24, d = 8;
|
|
468
468
|
let u = null;
|
|
469
|
-
for (const
|
|
470
|
-
const
|
|
471
|
-
if (t >=
|
|
472
|
-
u =
|
|
469
|
+
for (const w of e) {
|
|
470
|
+
const m = w.label || "Unlabeled", _ = this.ctx.measureText(m).width + r * 2;
|
|
471
|
+
if (t >= o && t <= o + _ && i >= c && i <= c + a) {
|
|
472
|
+
u = w;
|
|
473
473
|
break;
|
|
474
474
|
}
|
|
475
|
-
|
|
475
|
+
o += _ + d;
|
|
476
476
|
}
|
|
477
477
|
return this.ctx.restore(), u;
|
|
478
478
|
}
|
|
479
479
|
drawItem(t, i) {
|
|
480
|
-
var
|
|
480
|
+
var c;
|
|
481
481
|
if (this.visibleLabels.size > 0 && !this.visibleLabels.has(t.label) && !i)
|
|
482
482
|
return;
|
|
483
483
|
this.ctx.save();
|
|
484
|
-
const e = ((
|
|
485
|
-
if (this.ctx.strokeStyle =
|
|
486
|
-
const
|
|
487
|
-
this.ctx.strokeRect(u,
|
|
484
|
+
const e = ((c = t.style) == null ? void 0 : c.strokeColor) || "#FF4081", o = i ? "#00E5FF" : e;
|
|
485
|
+
if (this.ctx.strokeStyle = o, this.ctx.lineWidth = 2, i ? this.ctx.fillStyle = "rgba(0, 229, 255, 0.2)" : this.ctx.fillStyle = this.hexToRgba(e, 0.2), t.type === "rectangle") {
|
|
486
|
+
const r = t.coordinates, a = this.toScreenCoords(r.x1, r.y1), d = this.toScreenCoords(r.x2, r.y2), u = Math.min(a.x, d.x), w = Math.min(a.y, d.y), m = Math.abs(a.x - d.x), _ = Math.abs(a.y - d.y);
|
|
487
|
+
this.ctx.strokeRect(u, w, m, _), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fillRect(u, w, m, _), i && this.drawHandles(this.getAnnotationHandles(t));
|
|
488
488
|
} else if (t.type === "polygon") {
|
|
489
|
-
const
|
|
490
|
-
if (
|
|
489
|
+
const r = t.coordinates;
|
|
490
|
+
if (r.points.length === 0) {
|
|
491
491
|
this.ctx.restore();
|
|
492
492
|
return;
|
|
493
493
|
}
|
|
494
494
|
this.ctx.beginPath();
|
|
495
|
-
const
|
|
496
|
-
this.ctx.moveTo(
|
|
497
|
-
for (let
|
|
498
|
-
const u = this.toScreenCoords(
|
|
495
|
+
const a = this.toScreenCoords(r.points[0].x, r.points[0].y);
|
|
496
|
+
this.ctx.moveTo(a.x, a.y);
|
|
497
|
+
for (let d = 1; d < r.points.length; d++) {
|
|
498
|
+
const u = this.toScreenCoords(r.points[d].x, r.points[d].y);
|
|
499
499
|
this.ctx.lineTo(u.x, u.y);
|
|
500
500
|
}
|
|
501
501
|
if (!this.isDrawing || t !== this.activeAnnotation)
|
|
502
502
|
this.ctx.closePath();
|
|
503
503
|
else if (this.lastMouseMovePoint) {
|
|
504
|
-
let
|
|
505
|
-
if (this.isHoveringStartPoint &&
|
|
506
|
-
|
|
507
|
-
const
|
|
508
|
-
this.ctx.save(), this.ctx.beginPath(), this.ctx.arc(
|
|
504
|
+
let d = this.lastMouseMovePoint;
|
|
505
|
+
if (this.isHoveringStartPoint && r.points.length > 0) {
|
|
506
|
+
d = r.points[0];
|
|
507
|
+
const w = this.toScreenCoords(r.points[0].x, r.points[0].y);
|
|
508
|
+
this.ctx.save(), this.ctx.beginPath(), this.ctx.arc(w.x, w.y, 10, 0, Math.PI * 2), this.ctx.fillStyle = "rgba(255, 215, 0, 0.6)", this.ctx.strokeStyle = "#FFFFFF", this.ctx.lineWidth = 2, this.ctx.fill(), this.ctx.stroke(), this.ctx.restore();
|
|
509
509
|
}
|
|
510
|
-
const u = this.toScreenCoords(
|
|
510
|
+
const u = this.toScreenCoords(d.x, d.y);
|
|
511
511
|
this.ctx.lineTo(u.x, u.y);
|
|
512
512
|
}
|
|
513
513
|
this.ctx.stroke(), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fill(), i && this.drawHandles(this.getAnnotationHandles(t));
|
|
514
514
|
} else if (t.type === "rotatedRect") {
|
|
515
|
-
const
|
|
516
|
-
this.ctx.translate(this.toScreenCoords(
|
|
517
|
-
const
|
|
518
|
-
this.ctx.strokeRect(-
|
|
519
|
-
} else t.type === "point" && t.coordinates.points.forEach((
|
|
520
|
-
const
|
|
521
|
-
this.ctx.beginPath(), this.ctx.arc(
|
|
515
|
+
const r = t.coordinates;
|
|
516
|
+
this.ctx.translate(this.toScreenCoords(r.x, r.y).x, this.toScreenCoords(r.x, r.y).y), this.ctx.rotate(r.angle * Math.PI / 180);
|
|
517
|
+
const a = r.width * this.scale, d = r.height * this.scale;
|
|
518
|
+
this.ctx.strokeRect(-a / 2, -d / 2, a, d), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fillRect(-a / 2, -d / 2, a, d), this.ctx.rotate(-r.angle * Math.PI / 180), this.ctx.translate(-this.toScreenCoords(r.x, r.y).x, -this.toScreenCoords(r.x, r.y).y), i && this.drawHandles(this.getAnnotationHandles(t));
|
|
519
|
+
} else t.type === "point" && t.coordinates.points.forEach((a) => {
|
|
520
|
+
const d = this.toScreenCoords(a.x, a.y);
|
|
521
|
+
this.ctx.beginPath(), this.ctx.arc(d.x, d.y, 5, 0, Math.PI * 2), this.ctx.fillStyle = i ? "#00E5FF" : e, this.ctx.fill(), this.ctx.stroke();
|
|
522
522
|
});
|
|
523
523
|
this.ctx.restore();
|
|
524
524
|
}
|
|
@@ -561,28 +561,28 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
|
|
|
561
561
|
<path d="M637.12 693.376l182.208 182.208a32 32 0 1 1-45.248 45.248L591.872 738.624a352 352 0 1 1 45.248-45.248z m-45.248-45.248A288 288 0 1 0 183.872 240.128a288 288 0 0 0 408 408zM416 448h96a32 32 0 0 1 0 64h-96v96a32 32 0 0 1-64 0v-96h-96a32 32 0 0 1 0-64h96v-96a32 32 0 0 1 64 0v96z" fill="currentColor"/>\r
|
|
562
562
|
</svg>`, ve = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" width="1em" height="1em">\r
|
|
563
563
|
<path d="M637.12 693.376l182.208 182.208a32 32 0 1 1-45.248 45.248L591.872 738.624a352 352 0 1 1 45.248-45.248z m-45.248-45.248A288 288 0 1 0 183.872 240.128a288 288 0 0 0 408 408zM256 448h320a32 32 0 1 1 0 64H256a32 32 0 1 1 0-64z" fill="currentColor"/>\r
|
|
564
|
-
</svg>`, me = ["innerHTML"], fe = /* @__PURE__ */
|
|
564
|
+
</svg>`, me = ["innerHTML"], fe = /* @__PURE__ */ tt({
|
|
565
565
|
__name: "SvgIcon",
|
|
566
566
|
props: {
|
|
567
567
|
name: {},
|
|
568
568
|
size: {}
|
|
569
569
|
},
|
|
570
|
-
setup(
|
|
571
|
-
const t =
|
|
570
|
+
setup(f) {
|
|
571
|
+
const t = f, i = M(""), e = /* @__PURE__ */ Object.assign({ "../assets/svg/aim.svg": Qt, "../assets/svg/back.svg": te, "../assets/svg/connection.svg": ee, "../assets/svg/crop.svg": ne, "../assets/svg/delete.svg": se, "../assets/svg/download.svg": ie, "../assets/svg/edit.svg": oe, "../assets/svg/hide.svg": ae, "../assets/svg/pointer.svg": le, "../assets/svg/price-tag.svg": re, "../assets/svg/rank.svg": ce, "../assets/svg/refresh-right.svg": he, "../assets/svg/right.svg": de, "../assets/svg/view.svg": ge, "../assets/svg/zoom-in.svg": ue, "../assets/svg/zoom-out.svg": ve });
|
|
572
572
|
return Yt(() => {
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
}), (
|
|
576
|
-
class:
|
|
573
|
+
const o = `../assets/svg/${t.name}.svg`, c = e[o];
|
|
574
|
+
c ? i.value = c : (console.warn(`Icon ${t.name} not found at path ${o}`), i.value = "");
|
|
575
|
+
}), (o, c) => (y(), x("i", {
|
|
576
|
+
class: J(["svg-icon", [f.size ? `size-${f.size}` : ""]]),
|
|
577
577
|
innerHTML: i.value
|
|
578
578
|
}, null, 10, me));
|
|
579
579
|
}
|
|
580
|
-
}),
|
|
581
|
-
const i =
|
|
582
|
-
for (const [e,
|
|
583
|
-
i[e] =
|
|
580
|
+
}), et = (f, t) => {
|
|
581
|
+
const i = f.__vccOpts || f;
|
|
582
|
+
for (const [e, o] of t)
|
|
583
|
+
i[e] = o;
|
|
584
584
|
return i;
|
|
585
|
-
},
|
|
585
|
+
}, H = /* @__PURE__ */ et(fe, [["__scopeId", "data-v-3928607b"]]), ye = {
|
|
586
586
|
key: 0,
|
|
587
587
|
class: "image-list-sidebar"
|
|
588
588
|
}, pe = { class: "image-list-title" }, xe = { class: "image-list-scroll" }, be = ["onClick"], we = { class: "image-list-stage" }, Ce = ["src", "alt"], Ae = {
|
|
@@ -608,10 +608,10 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
|
|
|
608
608
|
}, Be = ["disabled"], De = ["disabled"], Ue = {
|
|
609
609
|
key: 2,
|
|
610
610
|
class: "right-sidebar"
|
|
611
|
-
}, Fe = { class: "label-list" },
|
|
611
|
+
}, Fe = { class: "label-list" }, Oe = { class: "label-row" }, Ee = ["onUpdate:modelValue", "onChange"], Ve = ["title"], Ne = ["onClick"], We = { class: "action-icon more-actions" }, Je = ["onClick"], je = {
|
|
612
612
|
key: 3,
|
|
613
613
|
class: "modal-overlay"
|
|
614
|
-
}, Ye = { class: "modal-content" }, Xe = { class: "form-group" }, qe = { class: "form-group" }, Ge = { class: "color-input-wrapper" }, Ke = /* @__PURE__ */
|
|
614
|
+
}, Ye = { class: "modal-content" }, Xe = { class: "form-group" }, qe = { class: "form-group" }, Ge = { class: "color-input-wrapper" }, Ke = /* @__PURE__ */ tt({
|
|
615
615
|
__name: "ImageAnnotator",
|
|
616
616
|
props: {
|
|
617
617
|
annotationTypes: { default: () => ["rectangle", "polygon", "point", "rotatedRect"] },
|
|
@@ -628,44 +628,44 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
|
|
|
628
628
|
maxZoom: {}
|
|
629
629
|
},
|
|
630
630
|
emits: ["annotationChange", "batchChange", "labelChange", "ready", "error", "tool:change", "viewport:change", "annotation:add", "annotation:update", "annotation:delete", "annotation:select", "prediction:loaded", "prediction:apply", "prediction:reject"],
|
|
631
|
-
setup(
|
|
632
|
-
const e =
|
|
633
|
-
if (!n ||
|
|
631
|
+
setup(f, { expose: t, emit: i }) {
|
|
632
|
+
const e = f, o = i, c = M(null), r = M(null), a = M(null), d = M(null), u = M(0), w = M(""), m = M([]), _ = M(""), U = M(!1), k = M({ name: "", color: "#FF0000" }), I = M("none"), C = M([]), R = M({}), N = D(() => d.value === "select" && !!w.value), j = (n) => {
|
|
633
|
+
if (!n || R.value[n]) return;
|
|
634
634
|
const s = new Image();
|
|
635
635
|
s.onload = () => {
|
|
636
|
-
const l = s.naturalWidth || 1,
|
|
637
|
-
|
|
638
|
-
...
|
|
639
|
-
[n]: { width: l, height:
|
|
636
|
+
const l = s.naturalWidth || 1, h = s.naturalHeight || 1;
|
|
637
|
+
R.value = {
|
|
638
|
+
...R.value,
|
|
639
|
+
[n]: { width: l, height: h }
|
|
640
640
|
};
|
|
641
641
|
}, s.src = n;
|
|
642
|
-
},
|
|
642
|
+
}, X = () => {
|
|
643
643
|
e.batchImages.forEach((n) => {
|
|
644
|
-
|
|
644
|
+
j(n.imageUrl);
|
|
645
645
|
});
|
|
646
|
-
},
|
|
647
|
-
var l,
|
|
646
|
+
}, O = () => {
|
|
647
|
+
var l, h, v, A;
|
|
648
648
|
const n = e.batchImages[u.value], s = (n == null ? void 0 : n.imageUrl) || ((l = e.image) == null ? void 0 : l.url);
|
|
649
649
|
return {
|
|
650
650
|
eventId: `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`,
|
|
651
651
|
timestamp: Date.now(),
|
|
652
652
|
requestId: e.requestId,
|
|
653
|
-
taskId: (
|
|
654
|
-
imageId: ((
|
|
655
|
-
operator: (
|
|
653
|
+
taskId: (h = e.session) == null ? void 0 : h.taskId,
|
|
654
|
+
imageId: ((v = e.image) == null ? void 0 : v.id) || s,
|
|
655
|
+
operator: (A = e.session) == null ? void 0 : A.userId
|
|
656
656
|
};
|
|
657
|
-
},
|
|
658
|
-
var
|
|
657
|
+
}, ht = (n) => {
|
|
658
|
+
var h;
|
|
659
659
|
const s = n == null ? void 0 : n.action;
|
|
660
660
|
if (!s) return;
|
|
661
661
|
const l = {
|
|
662
|
-
meta:
|
|
662
|
+
meta: O(),
|
|
663
663
|
action: s,
|
|
664
664
|
current: n == null ? void 0 : n.changedItem,
|
|
665
|
-
source: (
|
|
665
|
+
source: (h = n == null ? void 0 : n.changedItem) != null && h.predictionId ? "prediction" : "manual"
|
|
666
666
|
};
|
|
667
|
-
s === "add" &&
|
|
668
|
-
}, nt =
|
|
667
|
+
s === "add" && o("annotation:add", l), s === "update" && o("annotation:update", l), s === "delete" && o("annotation:delete", l), s === "select" && o("annotation:select", l);
|
|
668
|
+
}, nt = D(() => e.annotationTypes.filter((n) => n !== "category")), st = (n) => ({
|
|
669
669
|
rectangle: "crop",
|
|
670
670
|
polygon: "connection",
|
|
671
671
|
point: "aim",
|
|
@@ -679,253 +679,253 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
|
|
|
679
679
|
category: "分类标签"
|
|
680
680
|
})[n] || n;
|
|
681
681
|
Xt(() => {
|
|
682
|
-
if (
|
|
683
|
-
|
|
684
|
-
var l,
|
|
682
|
+
if (X(), c.value) {
|
|
683
|
+
a.value = new Zt(c.value), a.value.on("annotationChange", (s) => {
|
|
684
|
+
var l, h;
|
|
685
685
|
if (s.action === "add" && s.changedItem) {
|
|
686
|
-
const
|
|
687
|
-
|
|
686
|
+
const v = m.value.find((A) => A.id === _.value);
|
|
687
|
+
v && (s.changedItem.label = v.name, s.changedItem.labelId = v.id);
|
|
688
688
|
}
|
|
689
|
-
s.action === "select" ?
|
|
690
|
-
}),
|
|
689
|
+
s.action === "select" ? w.value = ((l = s.changedItem) == null ? void 0 : l.id) || "" : s.action === "delete" && ((h = s.changedItem) == null ? void 0 : h.id) === w.value && (w.value = ""), o("annotationChange", s), ht(s);
|
|
690
|
+
}), W(), E();
|
|
691
691
|
const n = new ResizeObserver(() => {
|
|
692
692
|
var s;
|
|
693
|
-
(s =
|
|
693
|
+
(s = a.value) == null || s.resize();
|
|
694
694
|
});
|
|
695
|
-
|
|
695
|
+
r.value && n.observe(r.value), e.defaultActiveType && p(e.defaultActiveType), o("ready", { meta: O() });
|
|
696
696
|
}
|
|
697
697
|
});
|
|
698
|
-
const
|
|
699
|
-
if (!
|
|
700
|
-
const n =
|
|
701
|
-
n &&
|
|
702
|
-
const s =
|
|
703
|
-
|
|
704
|
-
},
|
|
698
|
+
const E = () => {
|
|
699
|
+
if (!a.value) return;
|
|
700
|
+
const n = m.value.find((l) => l.id === _.value);
|
|
701
|
+
n && a.value.setLabelStyle(n.color);
|
|
702
|
+
const s = m.value.filter((l) => l.visible).map((l) => l.name);
|
|
703
|
+
a.value.setVisibleLabels(s);
|
|
704
|
+
}, W = () => {
|
|
705
705
|
var n;
|
|
706
|
-
if (
|
|
707
|
-
if (
|
|
706
|
+
if (a.value)
|
|
707
|
+
if (w.value = "", requestAnimationFrame(() => {
|
|
708
708
|
var s;
|
|
709
|
-
(s =
|
|
709
|
+
(s = a.value) == null || s.resize();
|
|
710
710
|
}), e.batchImages.length > 0) {
|
|
711
711
|
const s = e.batchImages[u.value];
|
|
712
|
-
|
|
713
|
-
} else (n = e.image) != null && n.url &&
|
|
714
|
-
},
|
|
712
|
+
a.value.loadImage(s.imageUrl), s.annotations ? a.value.setAnnotations(s.annotations) : a.value.setAnnotations([]);
|
|
713
|
+
} else (n = e.image) != null && n.url && a.value.loadImage(e.image.url);
|
|
714
|
+
}, p = (n) => {
|
|
715
715
|
var s, l;
|
|
716
|
-
if (
|
|
716
|
+
if (d.value = n, w.value = "", n !== "pan" && n !== "select" && m.value.length === 0) {
|
|
717
717
|
alert("请先创建标签!");
|
|
718
718
|
return;
|
|
719
719
|
}
|
|
720
|
-
n === "pan" || n === "select" ? (s =
|
|
721
|
-
},
|
|
720
|
+
n === "pan" || n === "select" ? (s = a.value) == null || s.setTool(n) : (l = a.value) == null || l.setTool(n), o("tool:change", { meta: O(), tool: n });
|
|
721
|
+
}, b = () => {
|
|
722
722
|
var n;
|
|
723
|
-
(n =
|
|
724
|
-
},
|
|
725
|
-
|
|
726
|
-
meta:
|
|
727
|
-
scale:
|
|
728
|
-
offset: { ...
|
|
723
|
+
(n = a.value) != null && n.activeAnnotation && a.value.deleteAnnotation(a.value.activeAnnotation.id);
|
|
724
|
+
}, z = () => {
|
|
725
|
+
a.value && o("viewport:change", {
|
|
726
|
+
meta: O(),
|
|
727
|
+
scale: a.value.scale,
|
|
728
|
+
offset: { ...a.value.offset }
|
|
729
729
|
});
|
|
730
|
-
},
|
|
730
|
+
}, q = () => {
|
|
731
731
|
var n;
|
|
732
|
-
(n =
|
|
733
|
-
},
|
|
732
|
+
(n = a.value) == null || n.zoom(1), z();
|
|
733
|
+
}, dt = () => {
|
|
734
734
|
var n;
|
|
735
|
-
(n =
|
|
735
|
+
(n = a.value) == null || n.zoom(-1), z();
|
|
736
736
|
}, xt = () => {
|
|
737
|
-
|
|
738
|
-
},
|
|
739
|
-
|
|
737
|
+
k.value = { name: "", color: "#2196F3" }, U.value = !0;
|
|
738
|
+
}, gt = () => {
|
|
739
|
+
U.value = !1;
|
|
740
740
|
}, bt = () => {
|
|
741
|
-
if (!
|
|
741
|
+
if (!k.value.name.trim()) {
|
|
742
742
|
alert("请输入标签名称");
|
|
743
743
|
return;
|
|
744
744
|
}
|
|
745
745
|
const s = {
|
|
746
746
|
id: Date.now().toString(),
|
|
747
|
-
name:
|
|
748
|
-
color:
|
|
747
|
+
name: k.value.name,
|
|
748
|
+
color: k.value.color,
|
|
749
749
|
visible: !0
|
|
750
750
|
};
|
|
751
|
-
|
|
752
|
-
},
|
|
751
|
+
m.value.push(s), o("labelChange", m.value), E(), m.value.length === 1 && G(s), gt();
|
|
752
|
+
}, G = (n) => {
|
|
753
753
|
var s;
|
|
754
|
-
|
|
754
|
+
_.value = n.id, (s = a.value) == null || s.setLabelStyle(n.color);
|
|
755
755
|
}, wt = (n, s) => {
|
|
756
756
|
if (!n.startsWith("#")) return n;
|
|
757
|
-
let l = 0,
|
|
758
|
-
return n.length === 4 ? (l = parseInt(n[1] + n[1], 16),
|
|
757
|
+
let l = 0, h = 0, v = 0;
|
|
758
|
+
return n.length === 4 ? (l = parseInt(n[1] + n[1], 16), h = parseInt(n[2] + n[2], 16), v = parseInt(n[3] + n[3], 16)) : n.length === 7 && (l = parseInt(n.slice(1, 3), 16), h = parseInt(n.slice(3, 5), 16), v = parseInt(n.slice(5, 7), 16)), `rgba(${l}, ${h}, ${v}, ${s})`;
|
|
759
759
|
}, Ct = (n) => {
|
|
760
760
|
var s;
|
|
761
|
-
if (n.id ===
|
|
762
|
-
const l =
|
|
763
|
-
let
|
|
764
|
-
l.forEach((
|
|
765
|
-
|
|
766
|
-
}),
|
|
761
|
+
if (n.id === _.value && ((s = a.value) == null || s.setLabelStyle(n.color)), a.value) {
|
|
762
|
+
const l = a.value.getAnnotations();
|
|
763
|
+
let h = !1;
|
|
764
|
+
l.forEach((v) => {
|
|
765
|
+
v.label === n.name && (v.style || (v.style = {}), v.style.strokeColor = n.color, v.style.fillColor = wt(n.color, 0.2), h = !0);
|
|
766
|
+
}), h && a.value.render();
|
|
767
767
|
}
|
|
768
|
-
|
|
768
|
+
o("labelChange", m.value), E();
|
|
769
769
|
}, At = (n) => {
|
|
770
|
-
n.visible = !n.visible,
|
|
770
|
+
n.visible = !n.visible, E();
|
|
771
771
|
}, _t = (n) => {
|
|
772
|
-
const s =
|
|
773
|
-
s > -1 && (
|
|
772
|
+
const s = m.value.findIndex((l) => l.id === n);
|
|
773
|
+
s > -1 && (m.value.splice(s, 1), o("labelChange", m.value), _.value === n && (_.value = m.value.length > 0 ? m.value[0].id : "", _.value && G(m.value[0])), E());
|
|
774
774
|
};
|
|
775
775
|
Y(() => e.labels, (n) => {
|
|
776
776
|
const s = JSON.parse(JSON.stringify(n || []));
|
|
777
|
-
if (
|
|
778
|
-
if (!
|
|
779
|
-
|
|
777
|
+
if (m.value = s, m.value.length > 0)
|
|
778
|
+
if (!_.value || !m.value.find((l) => l.id === _.value))
|
|
779
|
+
G(m.value[0]);
|
|
780
780
|
else {
|
|
781
|
-
const l =
|
|
782
|
-
l &&
|
|
781
|
+
const l = m.value.find((h) => h.id === _.value);
|
|
782
|
+
l && G(l);
|
|
783
783
|
}
|
|
784
784
|
else
|
|
785
|
-
|
|
786
|
-
|
|
785
|
+
_.value = "";
|
|
786
|
+
E();
|
|
787
787
|
}, { immediate: !0, deep: !0 });
|
|
788
788
|
const It = () => {
|
|
789
|
-
u.value > 0 && (ot(), u.value--,
|
|
789
|
+
u.value > 0 && (ot(), u.value--, W(), at());
|
|
790
790
|
}, kt = () => {
|
|
791
|
-
u.value < e.batchImages.length - 1 && (ot(), u.value++,
|
|
791
|
+
u.value < e.batchImages.length - 1 && (ot(), u.value++, W(), at());
|
|
792
792
|
}, ot = () => {
|
|
793
|
-
if (
|
|
794
|
-
const n =
|
|
793
|
+
if (a.value) {
|
|
794
|
+
const n = a.value.getAnnotations();
|
|
795
795
|
e.batchImages[u.value].annotations = n;
|
|
796
796
|
}
|
|
797
797
|
}, at = () => {
|
|
798
798
|
const n = e.batchImages[u.value];
|
|
799
|
-
|
|
799
|
+
o("batchChange", {
|
|
800
800
|
currentIndex: u.value,
|
|
801
801
|
total: e.batchImages.length,
|
|
802
802
|
currentImageUrl: n.imageUrl,
|
|
803
803
|
currentAnnotations: n.annotations || []
|
|
804
804
|
});
|
|
805
|
-
},
|
|
806
|
-
var
|
|
807
|
-
if (!
|
|
808
|
-
if (
|
|
809
|
-
|
|
805
|
+
}, ut = (n = []) => {
|
|
806
|
+
var v;
|
|
807
|
+
if (!a.value) return;
|
|
808
|
+
if (C.value = JSON.parse(JSON.stringify(n)), C.value.length === 0) {
|
|
809
|
+
I.value = "none";
|
|
810
810
|
return;
|
|
811
811
|
}
|
|
812
|
-
|
|
813
|
-
const l = (
|
|
814
|
-
const
|
|
815
|
-
return
|
|
812
|
+
I.value = "loaded";
|
|
813
|
+
const l = (a.value.getAnnotations() || []).filter((A) => !A.predictionId), h = C.value.map((A) => {
|
|
814
|
+
const $ = JSON.parse(JSON.stringify(A.annotation));
|
|
815
|
+
return $.id = $.id || `pred-${A.id}`, $.predictionId = A.id, $.modelRunId = A.modelRunId || $.modelRunId, $.confidence = A.confidence ?? $.confidence, $.reviewStatus = $.reviewStatus || "draft", $;
|
|
816
816
|
});
|
|
817
|
-
|
|
818
|
-
meta:
|
|
819
|
-
modelRunId: (
|
|
820
|
-
candidates:
|
|
817
|
+
a.value.setAnnotations([...l, ...h]), o("prediction:loaded", {
|
|
818
|
+
meta: O(),
|
|
819
|
+
modelRunId: (v = C.value[0]) == null ? void 0 : v.modelRunId,
|
|
820
|
+
candidates: C.value
|
|
821
821
|
});
|
|
822
822
|
}, St = (n, s) => {
|
|
823
|
-
var
|
|
824
|
-
if (!
|
|
825
|
-
|
|
826
|
-
const
|
|
827
|
-
return
|
|
828
|
-
|
|
829
|
-
}),
|
|
830
|
-
meta:
|
|
831
|
-
modelRunId: (
|
|
823
|
+
var v;
|
|
824
|
+
if (!a.value) return [];
|
|
825
|
+
I.value = "applying";
|
|
826
|
+
const h = (a.value.getAnnotations() || []).filter((A) => A.predictionId && n.includes(A.predictionId));
|
|
827
|
+
return h.forEach((A) => {
|
|
828
|
+
A.reviewStatus = "accepted";
|
|
829
|
+
}), I.value = "applied", o("prediction:apply", {
|
|
830
|
+
meta: O(),
|
|
831
|
+
modelRunId: (v = h[0]) == null ? void 0 : v.modelRunId,
|
|
832
832
|
candidateIds: n,
|
|
833
833
|
threshold: s,
|
|
834
|
-
acceptedAnnotations:
|
|
835
|
-
}),
|
|
834
|
+
acceptedAnnotations: h
|
|
835
|
+
}), a.value.render(), h;
|
|
836
836
|
}, Mt = (n, s) => {
|
|
837
|
-
var
|
|
838
|
-
if (!
|
|
839
|
-
const l =
|
|
840
|
-
|
|
841
|
-
meta:
|
|
842
|
-
modelRunId: (
|
|
837
|
+
var v;
|
|
838
|
+
if (!a.value) return;
|
|
839
|
+
const l = a.value.getAnnotations() || [], h = l.filter((A) => !(A.predictionId && n.includes(A.predictionId)));
|
|
840
|
+
a.value.setAnnotations(h), o("prediction:reject", {
|
|
841
|
+
meta: O(),
|
|
842
|
+
modelRunId: (v = l.find((A) => A.predictionId && n.includes(A.predictionId))) == null ? void 0 : v.modelRunId,
|
|
843
843
|
candidateIds: n,
|
|
844
844
|
reason: s
|
|
845
845
|
});
|
|
846
846
|
}, zt = (n, s = []) => {
|
|
847
|
-
|
|
847
|
+
a.value && (a.value.loadImage(n.url), a.value.setAnnotations(s));
|
|
848
848
|
}, $t = (n) => {
|
|
849
849
|
var s;
|
|
850
|
-
(s =
|
|
851
|
-
},
|
|
850
|
+
(s = a.value) == null || s.setAnnotations(n);
|
|
851
|
+
}, vt = () => {
|
|
852
852
|
var n;
|
|
853
|
-
return ((n =
|
|
853
|
+
return ((n = a.value) == null ? void 0 : n.getAnnotations()) || [];
|
|
854
854
|
}, Tt = (n = "json") => {
|
|
855
|
-
var l,
|
|
856
|
-
const s =
|
|
855
|
+
var l, h;
|
|
856
|
+
const s = vt();
|
|
857
857
|
return {
|
|
858
858
|
format: n,
|
|
859
|
-
image: ((l = e.batchImages[u.value]) == null ? void 0 : l.imageUrl) || ((
|
|
859
|
+
image: ((l = e.batchImages[u.value]) == null ? void 0 : l.imageUrl) || ((h = e.image) == null ? void 0 : h.url) || "",
|
|
860
860
|
annotations: s
|
|
861
861
|
};
|
|
862
|
-
},
|
|
863
|
-
n >= 0 && n < e.batchImages.length && (ot(), u.value = n,
|
|
862
|
+
}, mt = (n) => {
|
|
863
|
+
n >= 0 && n < e.batchImages.length && (ot(), u.value = n, W(), at());
|
|
864
864
|
}, Pt = (n) => {
|
|
865
865
|
var s;
|
|
866
|
-
return n === u.value &&
|
|
867
|
-
}, Ht = (n) => n.type === "rectangle", Lt = (n) => n.type === "polygon", Rt = (n) => n.type === "point", Bt = (n) => n.type === "rotatedRect",
|
|
868
|
-
var l,
|
|
869
|
-
const s = (l =
|
|
870
|
-
return ((
|
|
871
|
-
},
|
|
866
|
+
return n === u.value && a.value ? a.value.getAnnotations() || [] : ((s = e.batchImages[n]) == null ? void 0 : s.annotations) || [];
|
|
867
|
+
}, Ht = (n) => n.type === "rectangle", Lt = (n) => n.type === "polygon", Rt = (n) => n.type === "point", Bt = (n) => n.type === "rotatedRect", Z = (n) => {
|
|
868
|
+
var l, h;
|
|
869
|
+
const s = (l = m.value.find((v) => v.name === n.label)) == null ? void 0 : l.color;
|
|
870
|
+
return ((h = n.style) == null ? void 0 : h.strokeColor) || s || "#409eff";
|
|
871
|
+
}, ft = (n) => {
|
|
872
872
|
const s = n.coordinates;
|
|
873
873
|
return (s == null ? void 0 : s.points) || [];
|
|
874
|
-
},
|
|
874
|
+
}, Q = (n) => {
|
|
875
875
|
const s = e.batchImages[n];
|
|
876
876
|
if (s != null && s.width && (s != null && s.height))
|
|
877
877
|
return { width: s.width, height: s.height };
|
|
878
|
-
const l = s != null && s.imageUrl ?
|
|
879
|
-
return l || (s != null && s.imageUrl &&
|
|
878
|
+
const l = s != null && s.imageUrl ? R.value[s.imageUrl] : void 0;
|
|
879
|
+
return l || (s != null && s.imageUrl && j(s.imageUrl), { width: 1, height: 1 });
|
|
880
880
|
}, Dt = (n) => {
|
|
881
881
|
const s = e.batchImages[n];
|
|
882
|
-
return s != null && s.width && (s != null && s.height) ? !0 : s != null && s.imageUrl ? !!
|
|
882
|
+
return s != null && s.width && (s != null && s.height) ? !0 : s != null && s.imageUrl ? !!R.value[s.imageUrl] : !1;
|
|
883
883
|
}, Ut = (n, s) => {
|
|
884
|
-
const l = s.coordinates,
|
|
884
|
+
const l = s.coordinates, h = Q(n), v = Z(s), A = Math.min(l.x1, l.x2), $ = Math.min(l.y1, l.y2), Nt = Math.max(l.x1, l.x2), Wt = Math.max(l.y1, l.y2);
|
|
885
885
|
return {
|
|
886
|
-
left: `${
|
|
887
|
-
top: `${
|
|
888
|
-
width: `${(Nt -
|
|
889
|
-
height: `${(Wt -
|
|
890
|
-
borderColor:
|
|
891
|
-
backgroundColor: `${
|
|
886
|
+
left: `${A / h.width * 100}%`,
|
|
887
|
+
top: `${$ / h.height * 100}%`,
|
|
888
|
+
width: `${(Nt - A) / h.width * 100}%`,
|
|
889
|
+
height: `${(Wt - $) / h.height * 100}%`,
|
|
890
|
+
borderColor: v,
|
|
891
|
+
backgroundColor: `${v}22`
|
|
892
892
|
};
|
|
893
893
|
}, Ft = (n, s) => {
|
|
894
|
-
const l =
|
|
895
|
-
return
|
|
896
|
-
},
|
|
897
|
-
const s =
|
|
894
|
+
const l = Q(n);
|
|
895
|
+
return ft(s).map((h) => `${h.x / l.width * 100},${h.y / l.height * 100}`).join(" ");
|
|
896
|
+
}, Ot = (n) => {
|
|
897
|
+
const s = Z(n);
|
|
898
898
|
return {
|
|
899
899
|
fill: `${s}33`,
|
|
900
900
|
stroke: s,
|
|
901
901
|
strokeWidth: "1.4"
|
|
902
902
|
};
|
|
903
|
-
},
|
|
904
|
-
const
|
|
903
|
+
}, Et = (n, s, l) => {
|
|
904
|
+
const h = Q(n), v = Z(l);
|
|
905
905
|
return {
|
|
906
|
-
left: `${s.x /
|
|
907
|
-
top: `${s.y /
|
|
908
|
-
backgroundColor:
|
|
906
|
+
left: `${s.x / h.width * 100}%`,
|
|
907
|
+
top: `${s.y / h.height * 100}%`,
|
|
908
|
+
backgroundColor: v
|
|
909
909
|
};
|
|
910
910
|
}, Vt = (n, s) => {
|
|
911
|
-
const l = s.coordinates,
|
|
911
|
+
const l = s.coordinates, h = Q(n), v = Z(s), A = Math.abs(l.width), $ = Math.abs(l.height);
|
|
912
912
|
return {
|
|
913
|
-
left: `${(l.x -
|
|
914
|
-
top: `${(l.y -
|
|
915
|
-
width: `${
|
|
916
|
-
height: `${
|
|
913
|
+
left: `${(l.x - A / 2) / h.width * 100}%`,
|
|
914
|
+
top: `${(l.y - $ / 2) / h.height * 100}%`,
|
|
915
|
+
width: `${A / h.width * 100}%`,
|
|
916
|
+
height: `${$ / h.height * 100}%`,
|
|
917
917
|
transform: `rotate(${l.angle || 0}deg)`,
|
|
918
|
-
borderColor:
|
|
919
|
-
backgroundColor: `${
|
|
918
|
+
borderColor: v,
|
|
919
|
+
backgroundColor: `${v}22`
|
|
920
920
|
};
|
|
921
921
|
};
|
|
922
922
|
return t({
|
|
923
|
-
jumpTo:
|
|
923
|
+
jumpTo: mt,
|
|
924
924
|
setImage: zt,
|
|
925
925
|
setAnnotations: $t,
|
|
926
|
-
getAnnotations:
|
|
927
|
-
selectTool:
|
|
928
|
-
loadPredictionCandidates:
|
|
926
|
+
getAnnotations: vt,
|
|
927
|
+
selectTool: p,
|
|
928
|
+
loadPredictionCandidates: ut,
|
|
929
929
|
applyPredictions: St,
|
|
930
930
|
rejectPredictions: Mt,
|
|
931
931
|
exportAnnotations: Tt,
|
|
@@ -933,14 +933,14 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
|
|
|
933
933
|
var n, s;
|
|
934
934
|
return e.batchImages.length > 0 ? e.batchImages : [{
|
|
935
935
|
imageUrl: ((n = e.image) == null ? void 0 : n.url) || "",
|
|
936
|
-
annotations: ((s =
|
|
936
|
+
annotations: ((s = a.value) == null ? void 0 : s.getAnnotations()) || []
|
|
937
937
|
}];
|
|
938
938
|
},
|
|
939
939
|
getCurrentAnnotation: () => {
|
|
940
940
|
var n, s, l;
|
|
941
941
|
return {
|
|
942
942
|
imageUrl: ((n = e.batchImages[u.value]) == null ? void 0 : n.imageUrl) || ((s = e.image) == null ? void 0 : s.url) || "",
|
|
943
|
-
annotations: ((l =
|
|
943
|
+
annotations: ((l = a.value) == null ? void 0 : l.getAnnotations()) || []
|
|
944
944
|
};
|
|
945
945
|
}
|
|
946
946
|
}), Y(() => {
|
|
@@ -948,158 +948,158 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
|
|
|
948
948
|
return (n = e.image) == null ? void 0 : n.url;
|
|
949
949
|
}, () => {
|
|
950
950
|
var n;
|
|
951
|
-
e.batchImages.length === 0 && ((n = e.image) != null && n.url) &&
|
|
951
|
+
e.batchImages.length === 0 && ((n = e.image) != null && n.url) && W();
|
|
952
952
|
}), Y(() => e.predictionCandidates, (n) => {
|
|
953
|
-
n &&
|
|
953
|
+
n && ut(n);
|
|
954
954
|
}, { immediate: !0, deep: !0 }), Y(
|
|
955
955
|
() => e.batchImages.map((n) => `${n.imageUrl}:${n.width || ""}x${n.height || ""}`),
|
|
956
956
|
() => {
|
|
957
|
-
|
|
957
|
+
X();
|
|
958
958
|
},
|
|
959
959
|
{ immediate: !0 }
|
|
960
|
-
), (n, s) => (
|
|
961
|
-
class:
|
|
960
|
+
), (n, s) => (y(), x("div", {
|
|
961
|
+
class: J(["annotation-container", f.theme])
|
|
962
962
|
}, [
|
|
963
|
-
|
|
964
|
-
g("div", pe, "批量图片(" +
|
|
963
|
+
f.batchImages && f.batchImages.length > 0 ? (y(), x("div", ye, [
|
|
964
|
+
g("div", pe, "批量图片(" + P(f.batchImages.length) + ")", 1),
|
|
965
965
|
g("div", xe, [
|
|
966
|
-
(
|
|
967
|
-
key: `${l.imageUrl}-${
|
|
968
|
-
class:
|
|
969
|
-
onClick: (
|
|
966
|
+
(y(!0), x(B, null, F(f.batchImages, (l, h) => (y(), x("button", {
|
|
967
|
+
key: `${l.imageUrl}-${h}`,
|
|
968
|
+
class: J(["image-list-item", { active: h === u.value }]),
|
|
969
|
+
onClick: (v) => mt(h)
|
|
970
970
|
}, [
|
|
971
971
|
g("div", we, [
|
|
972
972
|
g("img", {
|
|
973
973
|
src: l.imageUrl,
|
|
974
|
-
alt: `第${
|
|
974
|
+
alt: `第${h + 1}张`,
|
|
975
975
|
class: "image-list-thumb"
|
|
976
976
|
}, null, 8, Ce),
|
|
977
|
-
Dt(
|
|
978
|
-
(
|
|
979
|
-
key:
|
|
977
|
+
Dt(h) ? (y(), x("div", Ae, [
|
|
978
|
+
(y(!0), x(B, null, F(Pt(h), (v) => (y(), x(B, {
|
|
979
|
+
key: v.id
|
|
980
980
|
}, [
|
|
981
|
-
Ht(
|
|
981
|
+
Ht(v) ? (y(), x("div", {
|
|
982
982
|
key: 0,
|
|
983
983
|
class: "thumb-overlay-rect",
|
|
984
|
-
style:
|
|
985
|
-
}, null, 4)) : Lt(
|
|
984
|
+
style: V(Ut(h, v))
|
|
985
|
+
}, null, 4)) : Lt(v) ? (y(), x("svg", _e, [
|
|
986
986
|
g("polygon", {
|
|
987
|
-
points: Ft(
|
|
988
|
-
style:
|
|
987
|
+
points: Ft(h, v),
|
|
988
|
+
style: V(Ot(v))
|
|
989
989
|
}, null, 12, Ie)
|
|
990
|
-
])) : Rt(
|
|
991
|
-
key: `${
|
|
990
|
+
])) : Rt(v) ? (y(!0), x(B, { key: 2 }, F(ft(v), (A, $) => (y(), x("div", {
|
|
991
|
+
key: `${v.id}-${$}`,
|
|
992
992
|
class: "thumb-overlay-point",
|
|
993
|
-
style:
|
|
994
|
-
}, null, 4))), 128)) : Bt(
|
|
993
|
+
style: V(Et(h, A, v))
|
|
994
|
+
}, null, 4))), 128)) : Bt(v) ? (y(), x("div", {
|
|
995
995
|
key: 3,
|
|
996
996
|
class: "thumb-overlay-rotated",
|
|
997
|
-
style:
|
|
998
|
-
}, null, 4)) :
|
|
997
|
+
style: V(Vt(h, v))
|
|
998
|
+
}, null, 4)) : T("", !0)
|
|
999
999
|
], 64))), 128))
|
|
1000
|
-
])) :
|
|
1000
|
+
])) : T("", !0)
|
|
1001
1001
|
]),
|
|
1002
|
-
g("span", ke, "第 " +
|
|
1002
|
+
g("span", ke, "第 " + P(h + 1) + " 张", 1)
|
|
1003
1003
|
], 10, be))), 128))
|
|
1004
1004
|
])
|
|
1005
|
-
])) :
|
|
1006
|
-
|
|
1005
|
+
])) : T("", !0),
|
|
1006
|
+
f.readOnly ? T("", !0) : (y(), x("div", Se, [
|
|
1007
1007
|
g("div", {
|
|
1008
|
-
class:
|
|
1009
|
-
onClick: s[0] || (s[0] = (l) =>
|
|
1008
|
+
class: J(["tool-btn", { active: d.value === "pan" }]),
|
|
1009
|
+
onClick: s[0] || (s[0] = (l) => p("pan")),
|
|
1010
1010
|
title: "拖动"
|
|
1011
1011
|
}, [
|
|
1012
|
-
H
|
|
1012
|
+
L(H, { name: "rank" })
|
|
1013
1013
|
], 2),
|
|
1014
1014
|
g("div", {
|
|
1015
|
-
class:
|
|
1016
|
-
onClick: s[1] || (s[1] = (l) =>
|
|
1015
|
+
class: J(["tool-btn", { active: d.value === "select" }]),
|
|
1016
|
+
onClick: s[1] || (s[1] = (l) => p("select")),
|
|
1017
1017
|
title: "选择"
|
|
1018
1018
|
}, [
|
|
1019
|
-
H
|
|
1019
|
+
L(H, { name: "pointer" })
|
|
1020
1020
|
], 2),
|
|
1021
1021
|
s[5] || (s[5] = g("div", { class: "divider" }, null, -1)),
|
|
1022
|
-
(
|
|
1022
|
+
(y(!0), x(B, null, F(nt.value, (l) => (y(), x("div", {
|
|
1023
1023
|
key: l,
|
|
1024
|
-
class:
|
|
1025
|
-
onClick: (
|
|
1024
|
+
class: J(["tool-btn", { active: d.value === l }]),
|
|
1025
|
+
onClick: (h) => p(l),
|
|
1026
1026
|
title: it(l)
|
|
1027
1027
|
}, [
|
|
1028
|
-
H
|
|
1028
|
+
L(H, {
|
|
1029
1029
|
name: st(l)
|
|
1030
1030
|
}, null, 8, ["name"])
|
|
1031
1031
|
], 10, Me))), 128)),
|
|
1032
1032
|
s[6] || (s[6] = g("div", { class: "divider" }, null, -1)),
|
|
1033
1033
|
g("div", {
|
|
1034
1034
|
class: "tool-btn",
|
|
1035
|
-
onClick:
|
|
1035
|
+
onClick: q,
|
|
1036
1036
|
title: "放大"
|
|
1037
1037
|
}, [
|
|
1038
|
-
H
|
|
1038
|
+
L(H, { name: "zoom-in" })
|
|
1039
1039
|
]),
|
|
1040
1040
|
g("div", {
|
|
1041
1041
|
class: "tool-btn",
|
|
1042
|
-
onClick:
|
|
1042
|
+
onClick: dt,
|
|
1043
1043
|
title: "缩小"
|
|
1044
1044
|
}, [
|
|
1045
|
-
H
|
|
1045
|
+
L(H, { name: "zoom-out" })
|
|
1046
1046
|
]),
|
|
1047
1047
|
s[7] || (s[7] = g("div", { class: "divider" }, null, -1)),
|
|
1048
|
-
|
|
1048
|
+
N.value ? (y(), x("div", {
|
|
1049
1049
|
key: 0,
|
|
1050
1050
|
class: "tool-btn",
|
|
1051
|
-
onClick:
|
|
1051
|
+
onClick: b,
|
|
1052
1052
|
title: "删除选中"
|
|
1053
1053
|
}, [
|
|
1054
|
-
H
|
|
1055
|
-
])) :
|
|
1054
|
+
L(H, { name: "delete" })
|
|
1055
|
+
])) : T("", !0)
|
|
1056
1056
|
])),
|
|
1057
1057
|
g("div", ze, [
|
|
1058
|
-
|
|
1058
|
+
f.readOnly ? T("", !0) : (y(), x("div", $e, [
|
|
1059
1059
|
g("div", Te, [
|
|
1060
1060
|
s[8] || (s[8] = g("span", { class: "label-text" }, "当前标签:", -1)),
|
|
1061
1061
|
g("div", Pe, [
|
|
1062
|
-
(
|
|
1062
|
+
(y(!0), x(B, null, F(m.value, (l) => (y(), x("div", {
|
|
1063
1063
|
key: l.id,
|
|
1064
|
-
class:
|
|
1065
|
-
style:
|
|
1066
|
-
onClick: (
|
|
1067
|
-
},
|
|
1068
|
-
|
|
1064
|
+
class: J(["tag-chip", { active: _.value === l.id }]),
|
|
1065
|
+
style: V({ backgroundColor: l.color, borderColor: l.color }),
|
|
1066
|
+
onClick: (h) => G(l)
|
|
1067
|
+
}, P(l.name), 15, He))), 128)),
|
|
1068
|
+
m.value.length === 0 ? (y(), x("div", Le, "请在右侧创建标签")) : T("", !0)
|
|
1069
1069
|
])
|
|
1070
1070
|
])
|
|
1071
1071
|
])),
|
|
1072
1072
|
g("div", {
|
|
1073
1073
|
class: "canvas-wrapper",
|
|
1074
1074
|
ref_key: "canvasWrapper",
|
|
1075
|
-
ref:
|
|
1075
|
+
ref: r,
|
|
1076
1076
|
onWheel: s[2] || (s[2] = qt(() => {
|
|
1077
1077
|
}, ["prevent"]))
|
|
1078
1078
|
}, [
|
|
1079
1079
|
g("canvas", {
|
|
1080
1080
|
ref_key: "canvasRef",
|
|
1081
|
-
ref:
|
|
1081
|
+
ref: c
|
|
1082
1082
|
}, null, 512)
|
|
1083
1083
|
], 544),
|
|
1084
|
-
|
|
1084
|
+
f.batchImages && f.batchImages.length > 0 ? (y(), x("div", Re, [
|
|
1085
1085
|
g("button", {
|
|
1086
1086
|
onClick: It,
|
|
1087
1087
|
disabled: u.value <= 0
|
|
1088
1088
|
}, [
|
|
1089
|
-
H
|
|
1090
|
-
s[9] || (s[9] =
|
|
1089
|
+
L(H, { name: "back" }),
|
|
1090
|
+
s[9] || (s[9] = K(" 上一张 ", -1))
|
|
1091
1091
|
], 8, Be),
|
|
1092
|
-
g("span", null,
|
|
1092
|
+
g("span", null, P(u.value + 1) + " / " + P(f.batchImages.length), 1),
|
|
1093
1093
|
g("button", {
|
|
1094
1094
|
onClick: kt,
|
|
1095
|
-
disabled: u.value >=
|
|
1095
|
+
disabled: u.value >= f.batchImages.length - 1
|
|
1096
1096
|
}, [
|
|
1097
|
-
s[10] || (s[10] =
|
|
1098
|
-
H
|
|
1097
|
+
s[10] || (s[10] = K(" 下一张 ", -1)),
|
|
1098
|
+
L(H, { name: "right" })
|
|
1099
1099
|
], 8, De)
|
|
1100
|
-
])) :
|
|
1100
|
+
])) : T("", !0)
|
|
1101
1101
|
]),
|
|
1102
|
-
|
|
1102
|
+
f.readOnly ? T("", !0) : (y(), x("div", Ue, [
|
|
1103
1103
|
g("div", { class: "sidebar-header" }, [
|
|
1104
1104
|
s[11] || (s[11] = g("h3", null, "标签管理", -1)),
|
|
1105
1105
|
g("button", {
|
|
@@ -1108,36 +1108,36 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
|
|
|
1108
1108
|
}, "添加标签")
|
|
1109
1109
|
]),
|
|
1110
1110
|
g("div", Fe, [
|
|
1111
|
-
(
|
|
1111
|
+
(y(!0), x(B, null, F(m.value, (l) => (y(), x("div", {
|
|
1112
1112
|
key: l.id,
|
|
1113
1113
|
class: "label-item"
|
|
1114
1114
|
}, [
|
|
1115
|
-
g("div",
|
|
1115
|
+
g("div", Oe, [
|
|
1116
1116
|
g("label", {
|
|
1117
1117
|
class: "color-wrapper",
|
|
1118
|
-
style:
|
|
1118
|
+
style: V({ backgroundColor: l.color })
|
|
1119
1119
|
}, [
|
|
1120
1120
|
lt(g("input", {
|
|
1121
1121
|
type: "color",
|
|
1122
|
-
"onUpdate:modelValue": (
|
|
1123
|
-
onChange: (
|
|
1122
|
+
"onUpdate:modelValue": (h) => l.color = h,
|
|
1123
|
+
onChange: (h) => Ct(l),
|
|
1124
1124
|
style: { visibility: "hidden", width: "0", height: "0" }
|
|
1125
|
-
}, null, 40,
|
|
1125
|
+
}, null, 40, Ee), [
|
|
1126
1126
|
[rt, l.color]
|
|
1127
1127
|
])
|
|
1128
1128
|
], 4),
|
|
1129
1129
|
g("span", {
|
|
1130
1130
|
class: "label-name",
|
|
1131
1131
|
title: l.name
|
|
1132
|
-
},
|
|
1132
|
+
}, P(l.name), 9, Ve),
|
|
1133
1133
|
g("span", {
|
|
1134
1134
|
class: "action-icon eye",
|
|
1135
|
-
onClick: (
|
|
1135
|
+
onClick: (h) => At(l)
|
|
1136
1136
|
}, [
|
|
1137
|
-
l.visible ? (
|
|
1137
|
+
l.visible ? (y(), yt(H, {
|
|
1138
1138
|
key: 0,
|
|
1139
1139
|
name: "view"
|
|
1140
|
-
})) : (
|
|
1140
|
+
})) : (y(), yt(H, {
|
|
1141
1141
|
key: 1,
|
|
1142
1142
|
name: "hide"
|
|
1143
1143
|
}))
|
|
@@ -1146,27 +1146,27 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
|
|
|
1146
1146
|
s[12] || (s[12] = g("span", { class: "dots" }, "•••", -1)),
|
|
1147
1147
|
g("span", {
|
|
1148
1148
|
class: "delete-btn",
|
|
1149
|
-
onClick: (
|
|
1149
|
+
onClick: (h) => _t(l.id),
|
|
1150
1150
|
title: "删除"
|
|
1151
1151
|
}, [
|
|
1152
|
-
H
|
|
1152
|
+
L(H, { name: "delete" })
|
|
1153
1153
|
], 8, Je)
|
|
1154
1154
|
])
|
|
1155
1155
|
])
|
|
1156
1156
|
]))), 128))
|
|
1157
1157
|
])
|
|
1158
1158
|
])),
|
|
1159
|
-
|
|
1159
|
+
U.value ? (y(), x("div", je, [
|
|
1160
1160
|
g("div", Ye, [
|
|
1161
1161
|
s[15] || (s[15] = g("h3", null, "新增标签", -1)),
|
|
1162
1162
|
g("div", Xe, [
|
|
1163
1163
|
s[13] || (s[13] = g("label", null, "名称", -1)),
|
|
1164
1164
|
lt(g("input", {
|
|
1165
|
-
"onUpdate:modelValue": s[3] || (s[3] = (l) =>
|
|
1165
|
+
"onUpdate:modelValue": s[3] || (s[3] = (l) => k.value.name = l),
|
|
1166
1166
|
placeholder: "请输入标签名称",
|
|
1167
1167
|
class: "modal-input"
|
|
1168
1168
|
}, null, 512), [
|
|
1169
|
-
[rt,
|
|
1169
|
+
[rt, k.value.name]
|
|
1170
1170
|
])
|
|
1171
1171
|
]),
|
|
1172
1172
|
g("div", qe, [
|
|
@@ -1174,17 +1174,17 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
|
|
|
1174
1174
|
g("div", Ge, [
|
|
1175
1175
|
lt(g("input", {
|
|
1176
1176
|
type: "color",
|
|
1177
|
-
"onUpdate:modelValue": s[4] || (s[4] = (l) =>
|
|
1177
|
+
"onUpdate:modelValue": s[4] || (s[4] = (l) => k.value.color = l),
|
|
1178
1178
|
class: "modal-color-picker"
|
|
1179
1179
|
}, null, 512), [
|
|
1180
|
-
[rt,
|
|
1180
|
+
[rt, k.value.color]
|
|
1181
1181
|
]),
|
|
1182
|
-
g("span", null,
|
|
1182
|
+
g("span", null, P(k.value.color), 1)
|
|
1183
1183
|
])
|
|
1184
1184
|
]),
|
|
1185
1185
|
g("div", { class: "modal-actions" }, [
|
|
1186
1186
|
g("button", {
|
|
1187
|
-
onClick:
|
|
1187
|
+
onClick: gt,
|
|
1188
1188
|
class: "cancel-btn"
|
|
1189
1189
|
}, "取消"),
|
|
1190
1190
|
g("button", {
|
|
@@ -1193,98 +1193,100 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
|
|
|
1193
1193
|
}, "确认")
|
|
1194
1194
|
])
|
|
1195
1195
|
])
|
|
1196
|
-
])) :
|
|
1196
|
+
])) : T("", !0)
|
|
1197
1197
|
], 2));
|
|
1198
1198
|
}
|
|
1199
|
-
}), Ze = /* @__PURE__ */
|
|
1199
|
+
}), Ze = /* @__PURE__ */ et(Ke, [["__scopeId", "data-v-ccc538f3"]]), Qe = {
|
|
1200
1200
|
class: "thumbnail-wrapper",
|
|
1201
1201
|
ref: "wrapper"
|
|
1202
|
-
}, tn = ["src", "alt"], en = ["viewBox", "preserveAspectRatio"], nn = ["x", "y", "width", "height", "stroke"], sn = ["points", "stroke"], on = ["x", "y", "fill"], an = {
|
|
1202
|
+
}, tn = ["src", "alt"], en = ["viewBox", "preserveAspectRatio"], nn = ["x", "y", "width", "height", "stroke", "stroke-width"], sn = ["points", "stroke", "stroke-width"], on = ["x", "y", "fill", "font-size"], an = {
|
|
1203
1203
|
key: 1,
|
|
1204
1204
|
class: "loading-placeholder"
|
|
1205
|
-
}, ln = /* @__PURE__ */
|
|
1205
|
+
}, ln = /* @__PURE__ */ tt({
|
|
1206
1206
|
__name: "AnnotationThumbnail",
|
|
1207
1207
|
props: {
|
|
1208
1208
|
src: {},
|
|
1209
1209
|
annotations: {},
|
|
1210
1210
|
alt: {},
|
|
1211
1211
|
labels: {},
|
|
1212
|
-
fit: {}
|
|
1212
|
+
fit: {},
|
|
1213
|
+
strokeWidth: {},
|
|
1214
|
+
fontSize: {}
|
|
1213
1215
|
},
|
|
1214
|
-
setup(
|
|
1215
|
-
const t =
|
|
1216
|
-
i.value && (
|
|
1217
|
-
},
|
|
1216
|
+
setup(f) {
|
|
1217
|
+
const t = f, i = M(null), e = M(!1), o = M(0), c = M(0), r = () => {
|
|
1218
|
+
i.value && (o.value = i.value.naturalWidth, c.value = i.value.naturalHeight, e.value = !0);
|
|
1219
|
+
}, a = D(() => t.fit === "contain" ? "xMidYMid meet" : "xMidYMid slice"), d = D(() => t.strokeWidth ?? 10), u = D(() => t.fontSize ?? 30), w = (k) => {
|
|
1218
1220
|
var I;
|
|
1219
|
-
if ((I =
|
|
1221
|
+
if ((I = k.style) != null && I.strokeColor) return k.style.strokeColor;
|
|
1220
1222
|
if (t.labels) {
|
|
1221
|
-
const C = t.labels.find((
|
|
1223
|
+
const C = t.labels.find((R) => R.name === k.label);
|
|
1222
1224
|
if (C) return C.color;
|
|
1223
1225
|
}
|
|
1224
1226
|
return "#FF0000";
|
|
1225
|
-
},
|
|
1226
|
-
const I =
|
|
1227
|
-
return { x: C, y:
|
|
1228
|
-
},
|
|
1229
|
-
if (
|
|
1230
|
-
const I =
|
|
1227
|
+
}, m = (k) => {
|
|
1228
|
+
const I = k.coordinates, C = Math.min(I.x1, I.x2), R = Math.min(I.y1, I.y2), N = Math.abs(I.x1 - I.x2), j = Math.abs(I.y1 - I.y2);
|
|
1229
|
+
return { x: C, y: R, width: N, height: j };
|
|
1230
|
+
}, _ = (k) => k.coordinates.points.map((C) => `${C.x},${C.y}`).join(" "), U = (k) => {
|
|
1231
|
+
if (k.type === "rectangle") {
|
|
1232
|
+
const I = m(k);
|
|
1231
1233
|
return { x: I.x, y: I.y - 5 };
|
|
1232
|
-
} else if (
|
|
1233
|
-
const I =
|
|
1234
|
+
} else if (k.type === "polygon") {
|
|
1235
|
+
const I = k.coordinates.points;
|
|
1234
1236
|
if (I.length > 0) return { x: I[0].x, y: I[0].y - 5 };
|
|
1235
1237
|
}
|
|
1236
1238
|
return { x: 0, y: 0 };
|
|
1237
1239
|
};
|
|
1238
|
-
return (
|
|
1240
|
+
return (k, I) => (y(), x("div", Qe, [
|
|
1239
1241
|
g("img", {
|
|
1240
1242
|
ref_key: "img",
|
|
1241
1243
|
ref: i,
|
|
1242
|
-
src:
|
|
1244
|
+
src: f.src,
|
|
1243
1245
|
class: "thumbnail-image",
|
|
1244
|
-
style:
|
|
1245
|
-
onLoad:
|
|
1246
|
-
alt:
|
|
1246
|
+
style: V({ objectFit: f.fit }),
|
|
1247
|
+
onLoad: r,
|
|
1248
|
+
alt: f.alt
|
|
1247
1249
|
}, null, 44, tn),
|
|
1248
|
-
e.value ? (
|
|
1250
|
+
e.value ? (y(), x("svg", {
|
|
1249
1251
|
key: 0,
|
|
1250
1252
|
class: "annotation-overlay",
|
|
1251
|
-
viewBox: `0 0 ${
|
|
1252
|
-
preserveAspectRatio:
|
|
1253
|
+
viewBox: `0 0 ${o.value} ${c.value}`,
|
|
1254
|
+
preserveAspectRatio: a.value
|
|
1253
1255
|
}, [
|
|
1254
|
-
(
|
|
1256
|
+
(y(!0), x(B, null, F(f.annotations, (C) => (y(), x(B, {
|
|
1255
1257
|
key: C.id
|
|
1256
1258
|
}, [
|
|
1257
|
-
C.type === "rectangle" ? (
|
|
1259
|
+
C.type === "rectangle" ? (y(), x("rect", {
|
|
1258
1260
|
key: 0,
|
|
1259
|
-
x:
|
|
1260
|
-
y:
|
|
1261
|
-
width:
|
|
1262
|
-
height:
|
|
1263
|
-
stroke:
|
|
1264
|
-
"stroke-width":
|
|
1261
|
+
x: m(C).x,
|
|
1262
|
+
y: m(C).y,
|
|
1263
|
+
width: m(C).width,
|
|
1264
|
+
height: m(C).height,
|
|
1265
|
+
stroke: w(C),
|
|
1266
|
+
"stroke-width": d.value,
|
|
1265
1267
|
fill: "transparent"
|
|
1266
|
-
}, null, 8, nn)) :
|
|
1267
|
-
C.type === "polygon" ? (
|
|
1268
|
+
}, null, 8, nn)) : T("", !0),
|
|
1269
|
+
C.type === "polygon" ? (y(), x("polygon", {
|
|
1268
1270
|
key: 1,
|
|
1269
|
-
points:
|
|
1270
|
-
stroke:
|
|
1271
|
-
"stroke-width":
|
|
1271
|
+
points: _(C),
|
|
1272
|
+
stroke: w(C),
|
|
1273
|
+
"stroke-width": d.value,
|
|
1272
1274
|
fill: "transparent"
|
|
1273
|
-
}, null, 8, sn)) :
|
|
1274
|
-
C.label ? (
|
|
1275
|
+
}, null, 8, sn)) : T("", !0),
|
|
1276
|
+
C.label ? (y(), x("text", {
|
|
1275
1277
|
key: 2,
|
|
1276
|
-
x:
|
|
1277
|
-
y:
|
|
1278
|
-
fill:
|
|
1279
|
-
"font-size":
|
|
1278
|
+
x: U(C).x,
|
|
1279
|
+
y: U(C).y,
|
|
1280
|
+
fill: w(C),
|
|
1281
|
+
"font-size": u.value,
|
|
1280
1282
|
"font-weight": "bold",
|
|
1281
1283
|
class: "anno-label"
|
|
1282
|
-
},
|
|
1284
|
+
}, P(C.label), 9, on)) : T("", !0)
|
|
1283
1285
|
], 64))), 128))
|
|
1284
|
-
], 8, en)) : (
|
|
1286
|
+
], 8, en)) : (y(), x("div", an, "Loading..."))
|
|
1285
1287
|
], 512));
|
|
1286
1288
|
}
|
|
1287
|
-
}), rn = /* @__PURE__ */
|
|
1289
|
+
}), rn = /* @__PURE__ */ et(ln, [["__scopeId", "data-v-d2fd08ec"]]), cn = {
|
|
1288
1290
|
key: 0,
|
|
1289
1291
|
class: "gallery-view"
|
|
1290
1292
|
}, hn = { class: "gallery-header" }, dn = { class: "label-summary" }, gn = ["onClick"], un = { class: "thumbnail-wrapper" }, vn = { class: "img-meta" }, mn = { class: "img-index" }, fn = { class: "anno-count" }, yn = {
|
|
@@ -1293,163 +1295,174 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
|
|
|
1293
1295
|
}, pn = {
|
|
1294
1296
|
key: 1,
|
|
1295
1297
|
class: "editor-view"
|
|
1296
|
-
}, xn = { class: "editor-header" }, bn = { class: "header-left" }, wn = { class: "editor-title" }, Cn = { class: "editor-content" }, An = /* @__PURE__ */
|
|
1298
|
+
}, xn = { class: "editor-header" }, bn = { class: "header-left" }, wn = { class: "editor-title" }, Cn = { class: "editor-content" }, An = /* @__PURE__ */ tt({
|
|
1297
1299
|
__name: "BatchAnnotator",
|
|
1298
1300
|
props: {
|
|
1299
1301
|
images: {},
|
|
1300
1302
|
labels: {},
|
|
1301
1303
|
actionBar: {},
|
|
1302
|
-
clickToEnterEditor: { type: Boolean }
|
|
1304
|
+
clickToEnterEditor: { type: Boolean },
|
|
1305
|
+
thumbStrokeWidth: {},
|
|
1306
|
+
thumbFontSize: {}
|
|
1303
1307
|
},
|
|
1304
|
-
emits: ["export", "update:images", "imageClick"],
|
|
1305
|
-
setup(
|
|
1306
|
-
const e =
|
|
1307
|
-
var
|
|
1308
|
-
return ((b = (
|
|
1309
|
-
}),
|
|
1310
|
-
var
|
|
1311
|
-
return ((b = (
|
|
1312
|
-
}),
|
|
1313
|
-
var
|
|
1314
|
-
return ((b = (
|
|
1315
|
-
}),
|
|
1316
|
-
var
|
|
1317
|
-
return ((b = (
|
|
1318
|
-
}),
|
|
1319
|
-
Y(() => e.images, (
|
|
1320
|
-
|
|
1308
|
+
emits: ["export", "update:images", "imageClick", "update:labels"],
|
|
1309
|
+
setup(f, { expose: t, emit: i }) {
|
|
1310
|
+
const e = f, o = i, c = M("gallery"), r = M([]), a = M([]), d = M(0), u = M(null), w = M(null), m = M(null), _ = D(() => {
|
|
1311
|
+
var p, b;
|
|
1312
|
+
return ((b = (p = e.actionBar) == null ? void 0 : p.annotateButton) == null ? void 0 : b.show) === !0;
|
|
1313
|
+
}), U = D(() => {
|
|
1314
|
+
var p, b;
|
|
1315
|
+
return ((b = (p = e.actionBar) == null ? void 0 : p.exportButton) == null ? void 0 : b.show) === !0;
|
|
1316
|
+
}), k = D(() => _.value || U.value), I = D(() => {
|
|
1317
|
+
var p, b;
|
|
1318
|
+
return ((b = (p = e.actionBar) == null ? void 0 : p.annotateButton) == null ? void 0 : b.text) || "手动标注";
|
|
1319
|
+
}), C = D(() => {
|
|
1320
|
+
var p, b;
|
|
1321
|
+
return ((b = (p = e.actionBar) == null ? void 0 : p.exportButton) == null ? void 0 : b.text) || "导出";
|
|
1322
|
+
}), R = D(() => e.clickToEnterEditor !== !1);
|
|
1323
|
+
Y(() => e.images, (p) => {
|
|
1324
|
+
r.value = JSON.parse(JSON.stringify(p));
|
|
1325
|
+
}, { immediate: !0, deep: !0 }), Y(() => e.labels, (p) => {
|
|
1326
|
+
a.value = JSON.parse(JSON.stringify(p || []));
|
|
1321
1327
|
}, { immediate: !0, deep: !0 });
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
var b,
|
|
1326
|
-
(
|
|
1328
|
+
const N = (p) => {
|
|
1329
|
+
d.value = p, c.value = "editor", m.value && (m.value.scrollTop = 0), Gt(() => {
|
|
1330
|
+
w.value && (w.value.scrollTop = 0), window.scrollTo(0, 0), requestAnimationFrame(() => {
|
|
1331
|
+
var b, z;
|
|
1332
|
+
(z = (b = u.value) == null ? void 0 : b.jumpTo) == null || z.call(b, p);
|
|
1327
1333
|
});
|
|
1328
1334
|
});
|
|
1329
|
-
},
|
|
1330
|
-
if (
|
|
1331
|
-
|
|
1335
|
+
}, j = (p, b) => {
|
|
1336
|
+
if (R.value) {
|
|
1337
|
+
N(p);
|
|
1332
1338
|
return;
|
|
1333
1339
|
}
|
|
1334
|
-
|
|
1335
|
-
},
|
|
1340
|
+
o("imageClick", { index: p, imageId: b.id, image: b });
|
|
1341
|
+
}, X = (p) => r.value.findIndex((b) => b.id === p);
|
|
1336
1342
|
t({
|
|
1337
|
-
openImageById: (
|
|
1338
|
-
const b =
|
|
1339
|
-
return b < 0 ? !1 : (
|
|
1343
|
+
openImageById: (p) => {
|
|
1344
|
+
const b = X(p);
|
|
1345
|
+
return b < 0 ? !1 : (N(b), !0);
|
|
1340
1346
|
},
|
|
1341
|
-
triggerImageClickById: (
|
|
1342
|
-
const b =
|
|
1347
|
+
triggerImageClickById: (p) => {
|
|
1348
|
+
const b = X(p);
|
|
1343
1349
|
if (b < 0)
|
|
1344
1350
|
return !1;
|
|
1345
|
-
const
|
|
1346
|
-
return
|
|
1347
|
-
}
|
|
1351
|
+
const z = r.value[b];
|
|
1352
|
+
return z ? (o("imageClick", { index: b, imageId: z.id, image: z }), !0) : !1;
|
|
1353
|
+
},
|
|
1354
|
+
getFinalData: () => ({
|
|
1355
|
+
images: JSON.parse(JSON.stringify(r.value)),
|
|
1356
|
+
labels: JSON.parse(JSON.stringify(a.value))
|
|
1357
|
+
})
|
|
1348
1358
|
});
|
|
1349
|
-
const
|
|
1350
|
-
if (
|
|
1351
|
-
const
|
|
1352
|
-
|
|
1359
|
+
const nt = () => {
|
|
1360
|
+
if (u.value && u.value.getCurrentAnnotation) {
|
|
1361
|
+
const p = u.value.getCurrentAnnotation();
|
|
1362
|
+
r.value[d.value] && (r.value[d.value].annotations = p.annotations);
|
|
1353
1363
|
}
|
|
1354
|
-
|
|
1355
|
-
},
|
|
1356
|
-
|
|
1357
|
-
},
|
|
1358
|
-
|
|
1359
|
-
},
|
|
1360
|
-
if (
|
|
1361
|
-
const b =
|
|
1362
|
-
|
|
1364
|
+
c.value = "gallery";
|
|
1365
|
+
}, st = () => {
|
|
1366
|
+
o("export", r.value);
|
|
1367
|
+
}, it = (p) => {
|
|
1368
|
+
d.value = p.currentIndex, r.value[p.currentIndex] && (r.value[p.currentIndex].annotations = p.currentAnnotations);
|
|
1369
|
+
}, E = (p) => {
|
|
1370
|
+
if (u.value && u.value.getCurrentAnnotation) {
|
|
1371
|
+
const b = u.value.getCurrentAnnotation();
|
|
1372
|
+
r.value[d.value] && (r.value[d.value].annotations = b.annotations, o("update:images", r.value));
|
|
1363
1373
|
}
|
|
1364
|
-
},
|
|
1374
|
+
}, W = (p) => {
|
|
1375
|
+
a.value = JSON.parse(JSON.stringify(p || [])), o("update:labels", a.value);
|
|
1365
1376
|
};
|
|
1366
|
-
return (
|
|
1377
|
+
return (p, b) => (y(), x("div", {
|
|
1367
1378
|
ref_key: "batchRootRef",
|
|
1368
|
-
ref:
|
|
1379
|
+
ref: w,
|
|
1369
1380
|
class: "batch-annotator"
|
|
1370
1381
|
}, [
|
|
1371
|
-
|
|
1382
|
+
c.value === "gallery" ? (y(), x("div", cn, [
|
|
1372
1383
|
g("div", hn, [
|
|
1373
|
-
g("h3", null, "批量查看与标注 (" +
|
|
1384
|
+
g("h3", null, "批量查看与标注 (" + P(r.value.length) + " 张)", 1),
|
|
1374
1385
|
g("div", dn, [
|
|
1375
|
-
(
|
|
1376
|
-
key:
|
|
1386
|
+
(y(!0), x(B, null, F(a.value, (z) => (y(), x("span", {
|
|
1387
|
+
key: z.id,
|
|
1377
1388
|
class: "label-badge",
|
|
1378
|
-
style:
|
|
1379
|
-
},
|
|
1389
|
+
style: V({ backgroundColor: z.color })
|
|
1390
|
+
}, P(z.name), 5))), 128))
|
|
1380
1391
|
])
|
|
1381
1392
|
]),
|
|
1382
1393
|
g("div", {
|
|
1383
1394
|
ref_key: "galleryGridRef",
|
|
1384
|
-
ref:
|
|
1395
|
+
ref: m,
|
|
1385
1396
|
class: "gallery-grid"
|
|
1386
1397
|
}, [
|
|
1387
|
-
(
|
|
1388
|
-
key:
|
|
1398
|
+
(y(!0), x(B, null, F(r.value, (z, q) => (y(), x("div", {
|
|
1399
|
+
key: q,
|
|
1389
1400
|
class: "gallery-item",
|
|
1390
|
-
onClick: (
|
|
1401
|
+
onClick: (dt) => j(q, z)
|
|
1391
1402
|
}, [
|
|
1392
1403
|
g("div", un, [
|
|
1393
|
-
|
|
1394
|
-
src:
|
|
1395
|
-
annotations:
|
|
1396
|
-
labels:
|
|
1397
|
-
fit: "cover"
|
|
1398
|
-
|
|
1404
|
+
L(rn, {
|
|
1405
|
+
src: z.imageUrl,
|
|
1406
|
+
annotations: z.annotations || [],
|
|
1407
|
+
labels: a.value,
|
|
1408
|
+
fit: "cover",
|
|
1409
|
+
strokeWidth: e.thumbStrokeWidth,
|
|
1410
|
+
fontSize: e.thumbFontSize
|
|
1411
|
+
}, null, 8, ["src", "annotations", "labels", "strokeWidth", "fontSize"])
|
|
1399
1412
|
]),
|
|
1400
1413
|
g("div", vn, [
|
|
1401
|
-
g("span", mn, "#" +
|
|
1402
|
-
g("span", fn,
|
|
1414
|
+
g("span", mn, "#" + P(q + 1), 1),
|
|
1415
|
+
g("span", fn, P((z.annotations || []).length) + " 标注", 1)
|
|
1403
1416
|
])
|
|
1404
1417
|
], 8, gn))), 128))
|
|
1405
1418
|
], 512),
|
|
1406
|
-
|
|
1407
|
-
|
|
1419
|
+
k.value ? (y(), x("div", yn, [
|
|
1420
|
+
_.value ? (y(), x("button", {
|
|
1408
1421
|
key: 0,
|
|
1409
1422
|
class: "action-btn primary",
|
|
1410
|
-
onClick: b[0] || (b[0] = (
|
|
1423
|
+
onClick: b[0] || (b[0] = (z) => N(0))
|
|
1411
1424
|
}, [
|
|
1412
|
-
H
|
|
1413
|
-
|
|
1414
|
-
])) :
|
|
1415
|
-
|
|
1425
|
+
L(H, { name: "edit" }),
|
|
1426
|
+
K(" " + P(I.value), 1)
|
|
1427
|
+
])) : T("", !0),
|
|
1428
|
+
U.value ? (y(), x("button", {
|
|
1416
1429
|
key: 1,
|
|
1417
1430
|
class: "action-btn success",
|
|
1418
|
-
onClick:
|
|
1431
|
+
onClick: st
|
|
1419
1432
|
}, [
|
|
1420
|
-
H
|
|
1421
|
-
|
|
1422
|
-
])) :
|
|
1423
|
-
])) :
|
|
1424
|
-
])) : (
|
|
1433
|
+
L(H, { name: "download" }),
|
|
1434
|
+
K(" " + P(C.value), 1)
|
|
1435
|
+
])) : T("", !0)
|
|
1436
|
+
])) : T("", !0)
|
|
1437
|
+
])) : (y(), x("div", pn, [
|
|
1425
1438
|
g("div", xn, [
|
|
1426
1439
|
g("div", bn, [
|
|
1427
1440
|
g("button", {
|
|
1428
1441
|
class: "back-btn",
|
|
1429
|
-
onClick:
|
|
1442
|
+
onClick: nt
|
|
1430
1443
|
}, [
|
|
1431
|
-
H
|
|
1432
|
-
b[1] || (b[1] =
|
|
1444
|
+
L(H, { name: "back" }),
|
|
1445
|
+
b[1] || (b[1] = K(" 返回列表 ", -1))
|
|
1433
1446
|
]),
|
|
1434
|
-
g("span", wn, "正在标注: " +
|
|
1447
|
+
g("span", wn, "正在标注: " + P(d.value + 1) + " / " + P(r.value.length), 1)
|
|
1435
1448
|
])
|
|
1436
1449
|
]),
|
|
1437
1450
|
g("div", Cn, [
|
|
1438
|
-
|
|
1451
|
+
L(Ze, {
|
|
1439
1452
|
ref_key: "annotatorRef",
|
|
1440
|
-
ref:
|
|
1441
|
-
batchImages:
|
|
1442
|
-
labels:
|
|
1453
|
+
ref: u,
|
|
1454
|
+
batchImages: r.value,
|
|
1455
|
+
labels: a.value,
|
|
1443
1456
|
annotationTypes: ["rectangle", "polygon", "point", "rotatedRect"],
|
|
1444
|
-
onBatchChange:
|
|
1445
|
-
onAnnotationChange:
|
|
1446
|
-
onLabelChange:
|
|
1457
|
+
onBatchChange: it,
|
|
1458
|
+
onAnnotationChange: E,
|
|
1459
|
+
onLabelChange: W
|
|
1447
1460
|
}, null, 8, ["batchImages", "labels"])
|
|
1448
1461
|
])
|
|
1449
1462
|
]))
|
|
1450
1463
|
], 512));
|
|
1451
1464
|
}
|
|
1452
|
-
}), kn = /* @__PURE__ */
|
|
1465
|
+
}), kn = /* @__PURE__ */ et(An, [["__scopeId", "data-v-0ae1040a"]]);
|
|
1453
1466
|
export {
|
|
1454
1467
|
kn as BatchAnnotator,
|
|
1455
1468
|
Ze as ImageAnnotator,
|