@glodon-aiot/dataset-annotation 3.13.0-alpha.28 → 3.14.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +151 -135
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +244 -218
- package/dist/es/components/DetectionAnnotation/index.mjs +258 -255
- package/dist/es/components/VLMAnnotation/RegionItem.mjs +135 -59
- package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +73 -62
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +55 -40
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +291 -162
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.mjs +100 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +88 -55
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.mjs +103 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +123 -91
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +42 -39
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +55 -60
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/ai.svg.mjs +4 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/error.svg.mjs +4 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/loading.svg.mjs +4 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/star.svg.mjs +4 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +512 -387
- package/dist/es/components/VLMAnnotation/constants.mjs +39 -32
- package/dist/es/components/VLMAnnotation/index.mjs +187 -150
- package/dist/es/index.mjs +1 -1
- package/dist/lib/index.js +4 -4
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +1 -0
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +3 -1
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.d.ts +16 -0
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +3 -2
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.d.ts +31 -0
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +5 -1
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +2 -1
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +2 -2
- package/dist/src/components/VLMAnnotation/constants.d.ts +19 -3
- package/dist/src/components/VLMAnnotation/index.d.ts +1 -1
- package/dist/src/components/VLMAnnotation/types.d.ts +15 -0
- package/package.json +2 -2
|
@@ -17,5 +17,6 @@ interface UseDeleteRegionParams {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare const useDeleteRegion: ({ canvas, onRegionChange, updateRegionNames, rectMapRef, textLayersMapRef, textLayoutContentMapRef, regionNameTextMapRef, ocrLoadingIconMapRef, }: UseDeleteRegionParams) => {
|
|
19
19
|
performDelete: (targetRect: fabric.Rect) => void;
|
|
20
|
+
deleteDirectly: (targetRect: fabric.Rect) => void;
|
|
20
21
|
};
|
|
21
22
|
export {};
|
|
@@ -15,18 +15,20 @@ interface UseDrawingModeParams {
|
|
|
15
15
|
updateRegionShapeAndImage: (rect: fabric.Rect) => void;
|
|
16
16
|
performOCRIfNeeded: (region: Region, action: 'create' | 'update') => Promise<void>;
|
|
17
17
|
createDeleteControl: () => fabric.Control;
|
|
18
|
+
createOCRControl: () => fabric.Control;
|
|
18
19
|
updateRegionNameText: (rect: fabric.Rect, region: Region) => void;
|
|
19
20
|
onRegionChange?: (region: Region | null, action: 'create' | 'update' | 'delete') => void;
|
|
20
21
|
onRegionSelect?: (region: Region | null) => void;
|
|
21
22
|
rectMapRef: React.MutableRefObject<Map<fabric.Rect, Region>>;
|
|
22
23
|
textLayersMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Rect[]>>;
|
|
24
|
+
setupBoundaryCheck: (rect: fabric.Rect) => (() => void) | undefined;
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* Hook for managing drawing mode (rectangle drawing functionality)
|
|
26
28
|
* @param params - Drawing mode configuration parameters
|
|
27
29
|
* @returns stopDraw function to stop drawing
|
|
28
30
|
*/
|
|
29
|
-
export declare const useDrawingMode: ({ canvas, drawingMode, draggable, setDrawingMode, canvasToImageCoords, labelDefinitions, onChange, cropRegionImage, updateRegionShapeAndImage, performOCRIfNeeded, createDeleteControl, updateRegionNameText, onRegionChange, onRegionSelect, rectMapRef, textLayersMapRef, }: UseDrawingModeParams) => {
|
|
31
|
+
export declare const useDrawingMode: ({ canvas, drawingMode, draggable, setDrawingMode, canvasToImageCoords, labelDefinitions, onChange, cropRegionImage, updateRegionShapeAndImage, performOCRIfNeeded, createDeleteControl, createOCRControl, updateRegionNameText, onRegionChange, onRegionSelect, rectMapRef, textLayersMapRef, setupBoundaryCheck, }: UseDrawingModeParams) => {
|
|
30
32
|
stopDraw: () => void;
|
|
31
33
|
};
|
|
32
34
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fabric } from 'fabric';
|
|
2
|
+
interface UseOCRControlParams {
|
|
3
|
+
performOCR: (targetRect: fabric.Rect) => void;
|
|
4
|
+
ocrRecognizingRef: React.MutableRefObject<Set<string>>;
|
|
5
|
+
ocrErrorRef: React.MutableRefObject<Set<string>>;
|
|
6
|
+
rectMapRef: React.MutableRefObject<Map<fabric.Rect, any>>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Hook for creating OCR control
|
|
10
|
+
* @param params - OCR control configuration parameters
|
|
11
|
+
* @returns createOCRControl function
|
|
12
|
+
*/
|
|
13
|
+
export declare const useOCRControl: ({ performOCR, ocrRecognizingRef, ocrErrorRef, rectMapRef, }: UseOCRControlParams) => {
|
|
14
|
+
createOCRControl: () => fabric.Control;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -11,7 +11,6 @@ interface UseOCRRecognitionParams {
|
|
|
11
11
|
onChange?: (labels: Region[]) => void;
|
|
12
12
|
updateTextLayers: (rect: fabric.Rect, region: Region) => void;
|
|
13
13
|
canvas: fabric.Canvas | undefined;
|
|
14
|
-
updateOCRLoadingIcon: (rect: fabric.Rect, region: Region, show: boolean) => void;
|
|
15
14
|
rectMapRef: React.MutableRefObject<Map<fabric.Rect, Region>>;
|
|
16
15
|
textLayersMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Rect[]>>;
|
|
17
16
|
textLayoutContentMapRef: React.MutableRefObject<Map<fabric.Rect, string>>;
|
|
@@ -21,8 +20,10 @@ interface UseOCRRecognitionParams {
|
|
|
21
20
|
* @param params - OCR recognition configuration parameters
|
|
22
21
|
* @returns performOCRIfNeeded function and ocrRecognizingRef
|
|
23
22
|
*/
|
|
24
|
-
export declare const useOCRRecognition: ({ ocrRecognize, onChange, updateTextLayers, canvas,
|
|
23
|
+
export declare const useOCRRecognition: ({ ocrRecognize, onChange, updateTextLayers, canvas, rectMapRef, textLayersMapRef, textLayoutContentMapRef, }: UseOCRRecognitionParams) => {
|
|
25
24
|
performOCRIfNeeded: (region: Region, action: "create" | "update") => Promise<void>;
|
|
25
|
+
performOCR: (region: Region) => Promise<void>;
|
|
26
26
|
ocrRecognizingRef: import('react').RefObject<Set<string>>;
|
|
27
|
+
ocrErrorRef: import('react').RefObject<Set<string>>;
|
|
27
28
|
};
|
|
28
29
|
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { fabric } from 'fabric';
|
|
2
|
+
interface UseRegionBoundaryCheckParams {
|
|
3
|
+
canvas: fabric.Canvas | undefined;
|
|
4
|
+
image: fabric.Image | undefined;
|
|
5
|
+
canvasToImageCoords: (canvasX: number, canvasY: number) => {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
imageToCanvasCoords: (imageX: number, imageY: number) => {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
bgImagePositionRef: React.MutableRefObject<{
|
|
14
|
+
left: number;
|
|
15
|
+
top: number;
|
|
16
|
+
}>;
|
|
17
|
+
bgImageSizeRef: React.MutableRefObject<{
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}>;
|
|
21
|
+
regionNameTextMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Text>>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Hook for checking and enforcing region boundary constraints
|
|
25
|
+
* @param params - Boundary check configuration parameters
|
|
26
|
+
* @returns setupBoundaryCheck function to setup boundary checking for a rect
|
|
27
|
+
*/
|
|
28
|
+
export declare const useRegionBoundaryCheck: ({ canvas, image, canvasToImageCoords, imageToCanvasCoords, bgImagePositionRef, bgImageSizeRef, regionNameTextMapRef, }: UseRegionBoundaryCheckParams) => {
|
|
29
|
+
setupBoundaryCheck: (rect: fabric.Rect) => (() => void) | undefined;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -26,12 +26,16 @@ interface UseRegionLoaderParams {
|
|
|
26
26
|
};
|
|
27
27
|
updateRegionShapeAndImage: (rect: fabric.Rect) => void;
|
|
28
28
|
createDeleteControl: () => fabric.Control;
|
|
29
|
+
createOCRControl: () => fabric.Control;
|
|
29
30
|
updateRegionNameText: (rect: fabric.Rect, region: Region) => void;
|
|
30
31
|
updateTextLayers: (rect: fabric.Rect, region: Region) => void;
|
|
32
|
+
setupBoundaryCheck: (rect: fabric.Rect) => (() => void) | undefined;
|
|
33
|
+
cropRegionImage: (region: Region) => Promise<string | undefined>;
|
|
34
|
+
onChange?: (regions: Region[]) => void;
|
|
31
35
|
}
|
|
32
36
|
/**
|
|
33
37
|
* Hook for loading labels from sample.labels
|
|
34
38
|
* @param params - Region loader configuration parameters
|
|
35
39
|
*/
|
|
36
|
-
export declare const useRegionLoader: ({ canvas, sample, image, bgImagePosition, canvasInitializedRef, bgImagePositionRef, sampleRef, labelsLoadedRef, rectMapRef, textLayersMapRef, textLayoutContentMapRef, regionNameTextMapRef, ocrLoadingIconMapRef, imageToCanvasCoords, updateRegionShapeAndImage, createDeleteControl, updateRegionNameText, updateTextLayers, }: UseRegionLoaderParams) => void;
|
|
40
|
+
export declare const useRegionLoader: ({ canvas, sample, image, bgImagePosition, canvasInitializedRef, bgImagePositionRef, sampleRef, labelsLoadedRef, rectMapRef, textLayersMapRef, textLayoutContentMapRef, regionNameTextMapRef, ocrLoadingIconMapRef, imageToCanvasCoords, updateRegionShapeAndImage, createDeleteControl, createOCRControl, updateRegionNameText, updateTextLayers, setupBoundaryCheck, cropRegionImage, onChange, }: UseRegionLoaderParams) => void;
|
|
37
41
|
export {};
|
|
@@ -4,6 +4,7 @@ interface UseRegionSelectionParams {
|
|
|
4
4
|
canvas: fabric.Canvas | undefined;
|
|
5
5
|
onRegionSelect?: (region: Region | null) => void;
|
|
6
6
|
createDeleteControl: () => fabric.Control;
|
|
7
|
+
createOCRControl: () => fabric.Control;
|
|
7
8
|
textLayersMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Rect[]>>;
|
|
8
9
|
rectMapRef: React.MutableRefObject<Map<fabric.Rect, Region>>;
|
|
9
10
|
}
|
|
@@ -11,5 +12,5 @@ interface UseRegionSelectionParams {
|
|
|
11
12
|
* Hook for managing region selection state
|
|
12
13
|
* @param params - Region selection configuration parameters
|
|
13
14
|
*/
|
|
14
|
-
export declare const useRegionSelection: ({ canvas, onRegionSelect, createDeleteControl, textLayersMapRef, rectMapRef, }: UseRegionSelectionParams) => void;
|
|
15
|
+
export declare const useRegionSelection: ({ canvas, onRegionSelect, createDeleteControl, createOCRControl, textLayersMapRef, rectMapRef, }: UseRegionSelectionParams) => void;
|
|
15
16
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { VLMLabelMakerProps } from '../types';
|
|
3
|
-
declare const VLMLabelMaker: React.
|
|
2
|
+
import { VLMLabelMakerProps, VLMLabelMakerRef } from '../types';
|
|
3
|
+
declare const VLMLabelMaker: React.ForwardRefExoticComponent<VLMLabelMakerProps & React.RefAttributes<VLMLabelMakerRef>>;
|
|
4
4
|
export default VLMLabelMaker;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* VLMAnnotation 组件相关的常量配置
|
|
3
3
|
*/
|
|
4
4
|
/** 最大缩放级别 */
|
|
5
|
-
export declare const MAX_ZOOM =
|
|
5
|
+
export declare const MAX_ZOOM = 8;
|
|
6
6
|
/** 最小缩放级别 */
|
|
7
7
|
export declare const MIN_ZOOM = 0.1;
|
|
8
8
|
/** 缩放因子(滚轮缩放时使用) */
|
|
@@ -15,6 +15,8 @@ export declare const ZOOM_STEP = 100;
|
|
|
15
15
|
export declare const BASE_STROKE_WIDTH = 2;
|
|
16
16
|
/** 矩形边框颜色 */
|
|
17
17
|
export declare const RECT_STROKE_COLOR = "#EAD4FF";
|
|
18
|
+
/** Active状态下的矩形边框颜色(高亮) */
|
|
19
|
+
export declare const ACTIVE_RECT_STROKE_COLOR = "#9C24F2";
|
|
18
20
|
/** 选中矩形的填充色 */
|
|
19
21
|
export declare const SELECTED_RECT_FILL_COLOR = "rgba(156, 36, 242, 0.1)";
|
|
20
22
|
/** 悬停矩形的填充色(比选中时更淡) */
|
|
@@ -56,7 +58,7 @@ export declare const OCR_SCAN_LINE_CORE_POSITION_MULTIPLIER = 1.5;
|
|
|
56
58
|
/** OCR 扫描线条核心高度倍数 */
|
|
57
59
|
export declare const OCR_SCAN_LINE_CORE_HEIGHT_MULTIPLIER = 0.5;
|
|
58
60
|
/** OCR 扫描动画速度(每次移动的距离相对于标注框高度) */
|
|
59
|
-
export declare const OCR_SCAN_ANIMATION_SPEED = 0.
|
|
61
|
+
export declare const OCR_SCAN_ANIMATION_SPEED = 0.003;
|
|
60
62
|
/** OCR 扫描线条光晕颜色 */
|
|
61
63
|
export declare const OCR_SCAN_LINE_GLOW_COLOR = "rgba(156, 36, 242, 0.2)";
|
|
62
64
|
/** OCR 扫描线条较亮层颜色 */
|
|
@@ -78,11 +80,19 @@ export declare const CONTROL_POINT_COLOR = "#9C24F2";
|
|
|
78
80
|
/** 控制点大小(像素) */
|
|
79
81
|
export declare const CONTROL_POINT_SIZE = 6;
|
|
80
82
|
/** 删除图标大小(像素) */
|
|
81
|
-
export declare const DELETE_ICON_SIZE =
|
|
83
|
+
export declare const DELETE_ICON_SIZE = 24;
|
|
82
84
|
/** 删除控件 X 轴偏移(像素) */
|
|
83
85
|
export declare const DELETE_CONTROL_OFFSET_X = 20;
|
|
84
86
|
/** 删除控件 Y 轴偏移(像素) */
|
|
85
87
|
export declare const DELETE_CONTROL_OFFSET_Y = 24;
|
|
88
|
+
/** AI图标大小(像素) */
|
|
89
|
+
export declare const AI_ICON_SIZE = 24;
|
|
90
|
+
/** AI控件 X 轴偏移(像素) */
|
|
91
|
+
export declare const AI_CONTROL_OFFSET_X = 20;
|
|
92
|
+
/** AI控件 Y 轴偏移(像素) */
|
|
93
|
+
export declare const AI_CONTROL_OFFSET_Y = 24;
|
|
94
|
+
/** AI控件与删除控件之间的间距(像素) */
|
|
95
|
+
export declare const AI_DELETE_CONTROL_SPACING = 40;
|
|
86
96
|
/** 区域名称文本颜色 */
|
|
87
97
|
export declare const REGION_NAME_TEXT_COLOR = "#9C24F2";
|
|
88
98
|
/** 图片导出格式 */
|
|
@@ -95,3 +105,9 @@ export declare const DELETE_MODAL_CONTENT = "\u786E\u5B9A\u8981\u5220\u9664\u6B6
|
|
|
95
105
|
export declare const DELETE_MODAL_OK_TEXT = "\u786E\u5B9A";
|
|
96
106
|
/** 删除确认弹框取消按钮文本 */
|
|
97
107
|
export declare const DELETE_MODAL_CANCEL_TEXT = "\u53D6\u6D88";
|
|
108
|
+
/** 画框模式十字线颜色 */
|
|
109
|
+
export declare const CROSSHAIR_LINE_COLOR = "rgba(156, 36, 242, 0.5)";
|
|
110
|
+
/** 画框模式十字线宽度(像素) */
|
|
111
|
+
export declare const CROSSHAIR_LINE_WIDTH = 1;
|
|
112
|
+
/** 画框模式十字线虚线样式 */
|
|
113
|
+
export declare const CROSSHAIR_LINE_DASH_ARRAY: [number, number];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { VLMAnnotationProps, VLMSample } from './types';
|
|
3
3
|
export declare const convertTopLeftToCenter: (sample: VLMSample) => VLMSample;
|
|
4
|
-
export type { ShapeType, Shape, Region, VLMSample, VLMLabelType, VLMLabel, VLMAnnotationProps, } from './types';
|
|
4
|
+
export type { ShapeType, Shape, Region, VLMSample, VLMLabelType, VLMLabel, VLMAnnotationProps, VLMLabelMakerRef, } from './types';
|
|
5
5
|
declare const VLMAnnotation: React.FC<VLMAnnotationProps>;
|
|
6
6
|
export default VLMAnnotation;
|
|
@@ -82,6 +82,11 @@ export interface VLMAnnotationProps {
|
|
|
82
82
|
hideRightSide?: boolean;
|
|
83
83
|
readOnly?: boolean;
|
|
84
84
|
}
|
|
85
|
+
export interface VLMLabelMakerRef {
|
|
86
|
+
performOCRById: (regionId: string) => void;
|
|
87
|
+
ocrRecognizingRef: React.MutableRefObject<Set<string>>;
|
|
88
|
+
ocrErrorRef: React.MutableRefObject<Set<string>>;
|
|
89
|
+
}
|
|
85
90
|
export interface VLMLabelMakerProps {
|
|
86
91
|
sample?: VLMSample;
|
|
87
92
|
labelDefinitions?: VLMLabel[];
|
|
@@ -140,6 +145,11 @@ export interface TextAnnotationPanelProps {
|
|
|
140
145
|
label: VLMLabel;
|
|
141
146
|
region: Region;
|
|
142
147
|
}, index?: number) => void;
|
|
148
|
+
onDelete?: (regionId: string) => void;
|
|
149
|
+
onRegionClick?: (region: Region) => void;
|
|
150
|
+
onOCR?: (regionId: string) => void;
|
|
151
|
+
ocrRecognizing?: Set<string>;
|
|
152
|
+
ocrErrors?: Set<string>;
|
|
143
153
|
readOnly?: boolean;
|
|
144
154
|
}
|
|
145
155
|
export interface RegionItemProps {
|
|
@@ -152,6 +162,11 @@ export interface RegionItemProps {
|
|
|
152
162
|
onChange?: (labelId: string, value: string) => void;
|
|
153
163
|
onFocus?: (labelId: string, value: string) => void;
|
|
154
164
|
onBlur?: (labelId: string, value: string) => void;
|
|
165
|
+
onDelete?: (regionId: string) => void;
|
|
166
|
+
onRegionClick?: (region: Region) => void;
|
|
167
|
+
onOCR?: (regionId: string) => void;
|
|
168
|
+
isOCRRecognizing?: boolean;
|
|
169
|
+
hasOCRError?: boolean;
|
|
155
170
|
readOnly?: boolean;
|
|
156
171
|
}
|
|
157
172
|
export interface ImageAnnotationDebuggerProps {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glodon-aiot/dataset-annotation",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0-alpha.30",
|
|
4
4
|
"module": "./dist/es/index.mjs",
|
|
5
5
|
"main": "./dist/lib/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ant-design/icons": "^5.3.4",
|
|
39
39
|
"@aws-crypto/sha256-js": "^3.0.0",
|
|
40
|
-
"@glodon-aiot/apis": "^3.
|
|
40
|
+
"@glodon-aiot/apis": "^3.14.0-alpha.30",
|
|
41
41
|
"@glodon-aiot/minio": "^0.1.6",
|
|
42
42
|
"@reduxjs/toolkit": "^1.9.5",
|
|
43
43
|
"@types/fabric": "^5.3.2",
|