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