@glodon-aiot/dataset-annotation 3.14.0-alpha.32 → 3.14.0-alpha.34

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.
Files changed (26) hide show
  1. package/dist/es/components/VLMAnnotation/RegionItem.mjs +1 -1
  2. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useAIButtonHover.mjs +193 -0
  3. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +300 -237
  4. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +158 -56
  5. package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +424 -397
  6. package/dist/es/components/VLMAnnotation/components/AIErrorTooltip/AIErrorTooltip.less.mjs +4 -0
  7. package/dist/es/components/VLMAnnotation/components/AIErrorTooltip/index.mjs +24 -0
  8. package/dist/es/components/VLMAnnotation/components/ZoomControls.mjs +1 -1
  9. package/dist/es/components/VLMAnnotation/constants.mjs +1 -1
  10. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.mjs +217 -167
  11. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.mjs +114 -122
  12. package/dist/es/components/VLMAnnotationDetail/VLMDetail/index.mjs +445 -0
  13. package/dist/es/components/VLMAnnotationDetail/VlmModal/index.mjs +249 -113
  14. package/dist/es/components/VLMAnnotationDetail/index.mjs +219 -213
  15. package/dist/es/index.mjs +1 -1
  16. package/dist/lib/index.js +4 -4
  17. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useAIButtonHover.d.ts +16 -0
  18. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +2 -1
  19. package/dist/src/components/VLMAnnotation/components/AIErrorTooltip/index.d.ts +8 -0
  20. package/dist/src/components/VLMAnnotation/constants.d.ts +2 -2
  21. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.d.ts +1 -0
  22. package/dist/src/components/VLMAnnotationDetail/VLMDetail/index.d.ts +21 -0
  23. package/dist/src/components/VLMAnnotationDetail/VlmModal/index.d.ts +11 -2
  24. package/package.json +2 -2
  25. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/index.mjs +0 -455
  26. /package/dist/es/components/VLMAnnotationDetail/{MarkVLMBoxModal → VLMDetail}/style.less.mjs +0 -0
@@ -69,7 +69,7 @@ const F = ({
69
69
  }), /* @__PURE__ */ i("div", {
70
70
  className: "vlm-text-region-actions",
71
71
  children: [!d && M && /* @__PURE__ */ e(V, {
72
- title: p ? "识别中..." : w ? "识别失败,点击重试" : "OCR识别",
72
+ title: p ? "识别中..." : w ? "预置服务调用失败" : "OCR识别",
73
73
  children: /* @__PURE__ */ e("span", {
74
74
  className: `vlm-text-region-ocr-btn ${p ? "vlm-text-region-ocr-btn-loading" : ""} ${w ? "vlm-text-region-ocr-btn-error" : ""}`,
75
75
  onClick: (t) => {
@@ -0,0 +1,193 @@
1
+ import { useRef as rt, useEffect as ft } from "react";
2
+ import { fabric as Z } from "fabric";
3
+ import { AI_CONTROL_OFFSET_X as ut, AI_CONTROL_OFFSET_Y as Ct, AI_ICON_SIZE as st } from "../../constants.mjs";
4
+ const Ft = ({
5
+ canvas: l,
6
+ ocrErrorRef: k,
7
+ rectMapRef: D,
8
+ onAIButtonHover: n
9
+ }) => {
10
+ const G = rt(null), J = rt(null);
11
+ ft(() => {
12
+ if (!l || !n)
13
+ return;
14
+ const O = /* @__PURE__ */ new Map(), lt = (S) => {
15
+ var h;
16
+ const a = (h = S.controls) == null ? void 0 : h.ocrControl;
17
+ if (!a)
18
+ return;
19
+ const E = a.render;
20
+ E && !a._intercepted && (a.render = (q, F, c, i, _) => {
21
+ O.set(S, {
22
+ x: F,
23
+ y: c
24
+ }), E && E(q, F, c, i, _);
25
+ }, a._intercepted = !0);
26
+ }, K = (S) => {
27
+ var et;
28
+ const a = S.e, h = l.getElement().getBoundingClientRect(), q = a.clientX - h.left, F = a.clientY - h.top;
29
+ let c = null, i = null;
30
+ const _ = l.getActiveObject();
31
+ if (!_ || !(_ instanceof Z.Rect)) {
32
+ n(null, null);
33
+ return;
34
+ }
35
+ const o = _, W = D.current.get(o);
36
+ if (!W) {
37
+ n(null, null);
38
+ return;
39
+ }
40
+ const $ = W.id;
41
+ if (!k.current.has($)) {
42
+ n(null, null);
43
+ return;
44
+ }
45
+ const y = (et = o.controls) == null ? void 0 : et.ocrControl;
46
+ if (!y) {
47
+ n(null, null);
48
+ return;
49
+ }
50
+ const U = ut, V = Ct + st + 4;
51
+ lt(o);
52
+ let x = O.get(o);
53
+ if (!x) {
54
+ try {
55
+ if (o._calcControlPosition && typeof o._calcControlPosition == "function") {
56
+ const t = o._calcControlPosition(y);
57
+ t && (x = {
58
+ x: t.x,
59
+ y: t.y
60
+ }, O.set(o, x));
61
+ }
62
+ } catch (t) {
63
+ }
64
+ if (!x)
65
+ try {
66
+ const t = o.getCoords();
67
+ if (t && t.length >= 4) {
68
+ const e = t[1], L = t[2], f = t[0], M = e, u = {
69
+ x: L.x - e.x,
70
+ y: L.y - e.y
71
+ }, C = {
72
+ x: f.x - e.x,
73
+ y: f.y - e.y
74
+ }, r = Math.sqrt(u.x * u.x + u.y * u.y), s = Math.sqrt(C.x * C.x + C.y * C.y), b = r > 1e-3 ? {
75
+ x: u.x / r,
76
+ y: u.y / r
77
+ } : {
78
+ x: 1,
79
+ y: 0
80
+ }, P = s > 1e-3 ? {
81
+ x: C.x / s,
82
+ y: C.y / s
83
+ } : {
84
+ x: 0,
85
+ y: -1
86
+ }, T = M.x + b.x * U - P.x * V, z = M.y + b.y * U - P.y * V;
87
+ x = {
88
+ x: T,
89
+ y: z
90
+ }, O.set(o, x);
91
+ }
92
+ } catch (t) {
93
+ console.warn("[useAIButtonHover] Failed to calculate control position:", t);
94
+ }
95
+ }
96
+ const d = o.getCoords();
97
+ if (!d || d.length < 4) {
98
+ n(null, null);
99
+ return;
100
+ }
101
+ const A = d[0], R = d[1], H = d[2];
102
+ d[3];
103
+ const B = R, p = {
104
+ x: H.x - R.x,
105
+ y: H.y - R.y
106
+ }, m = {
107
+ x: A.x - R.x,
108
+ y: A.y - R.y
109
+ }, I = Math.sqrt(p.x * p.x + p.y * p.y), N = Math.sqrt(m.x * m.x + m.y * m.y), tt = I > 1e-3 ? {
110
+ x: p.x / I,
111
+ y: p.y / I
112
+ } : {
113
+ x: 1,
114
+ y: 0
115
+ }, ot = N > 1e-3 ? {
116
+ x: m.x / N,
117
+ y: m.y / N
118
+ } : {
119
+ x: 0,
120
+ y: -1
121
+ }, it = B.x + tt.x * U - ot.x * V, yt = B.y + tt.y * U - ot.y * V, v = st / 2, w = 8;
122
+ let g = null;
123
+ try {
124
+ if (o._calcControlPosition && typeof o._calcControlPosition == "function") {
125
+ const t = o._calcControlPosition(y);
126
+ t && (g = {
127
+ x: t.x,
128
+ y: t.y
129
+ });
130
+ }
131
+ if (!g && o.calcCoords) {
132
+ const t = o.calcCoords();
133
+ if (t && y.x !== void 0 && y.y !== void 0) {
134
+ const e = y.x, L = y.y, f = y.offsetX || 0, M = y.offsetY || 0, u = t.tr.x, C = t.tr.y, r = {
135
+ x: t.br.x - t.tr.x,
136
+ y: t.br.y - t.tr.y
137
+ }, s = {
138
+ x: t.tl.x - t.tr.x,
139
+ y: t.tl.y - t.tr.y
140
+ }, b = Math.sqrt(r.x * r.x + r.y * r.y), P = Math.sqrt(s.x * s.x + s.y * s.y), T = b > 1e-3 ? {
141
+ x: r.x / b,
142
+ y: r.y / b
143
+ } : {
144
+ x: 1,
145
+ y: 0
146
+ }, z = P > 1e-3 ? {
147
+ x: s.x / P,
148
+ y: s.y / P
149
+ } : {
150
+ x: 0,
151
+ y: -1
152
+ }, xt = u + T.x * f - z.x * M, at = C + T.y * f - z.y * M;
153
+ g = {
154
+ x: xt,
155
+ y: at
156
+ };
157
+ }
158
+ }
159
+ } catch (t) {
160
+ console.warn("[useAIButtonHover] Failed to calculate fabric control position:", t);
161
+ }
162
+ const nt = l.viewportTransform;
163
+ if (!nt) {
164
+ n(null, null);
165
+ return;
166
+ }
167
+ let X, Y;
168
+ if (x)
169
+ X = x.x, Y = x.y;
170
+ else {
171
+ const t = g ? g.x : it, e = g ? g.y : yt, L = new Z.Point(t, e), f = Z.util.transformPoint(L, nt);
172
+ X = f.x, Y = f.y;
173
+ }
174
+ if (q >= X - v - w && q <= X + v + w && F >= Y - v - w && F <= Y + v + w) {
175
+ const t = h.left + X, e = h.top + Y;
176
+ c = $, i = {
177
+ x: t,
178
+ y: e
179
+ };
180
+ }
181
+ const ct = G.current, j = J.current;
182
+ (c !== ct || c && i && (!j || j.x !== i.x || j.y !== i.y) || !c && ct !== null) && (c && i ? n(c, i) : n(null, null), G.current = c, J.current = i);
183
+ }, Q = () => {
184
+ n && n(null, null);
185
+ };
186
+ return l.on("mouse:move", K), l.on("mouse:out", Q), () => {
187
+ l.off("mouse:move", K), l.off("mouse:out", Q);
188
+ };
189
+ }, [l, k, D, n]);
190
+ };
191
+ export {
192
+ Ft as useAIButtonHover
193
+ };