@glodon-aiot/dataset-annotation 3.9.0-beta.9 → 3.10.0-alpha.11

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 (98) hide show
  1. package/dist/es/DatasetContext/index.mjs +6 -3
  2. package/dist/es/components/Iconfont/index.mjs +2 -2
  3. package/dist/es/components/PicZipImportModal/config.mjs +41 -0
  4. package/dist/es/components/PicZipImportModal/index.mjs +317 -301
  5. package/dist/es/components/PicZipImportModal/pic_vlm_json_zip.svg.mjs +4 -0
  6. package/dist/es/components/PicZipImportModal/pic_vlm_zip.svg.mjs +4 -0
  7. package/dist/es/components/VLMAnnotation/RegionItem.mjs +95 -0
  8. package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +83 -0
  9. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.mjs +75 -0
  10. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.mjs +115 -0
  11. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.mjs +42 -0
  12. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.mjs +55 -0
  13. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.mjs +51 -0
  14. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +47 -0
  15. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +220 -0
  16. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.mjs +106 -0
  17. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +68 -0
  18. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.mjs +38 -0
  19. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +141 -0
  20. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.mjs +72 -0
  21. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +102 -0
  22. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +103 -0
  23. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.mjs +156 -0
  24. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/del.png.mjs +4 -0
  25. package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +507 -0
  26. package/dist/es/components/VLMAnnotation/VLMLabelMaker/style.less.mjs +4 -0
  27. package/dist/es/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.mjs +33 -0
  28. package/dist/es/components/VLMAnnotation/components/DragButton.mjs +18 -0
  29. package/dist/es/components/VLMAnnotation/components/FitToScreenButton.mjs +16 -0
  30. package/dist/es/components/VLMAnnotation/components/RectangleButton.mjs +30 -0
  31. package/dist/es/components/VLMAnnotation/components/Toolbar.mjs +40 -0
  32. package/dist/es/components/VLMAnnotation/components/ZoomControls.mjs +44 -0
  33. package/dist/es/components/VLMAnnotation/constants.mjs +50 -0
  34. package/dist/es/components/VLMAnnotation/index.mjs +242 -0
  35. package/dist/es/components/VLMAnnotation/style.less.mjs +4 -0
  36. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.mjs +345 -0
  37. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/style.less.mjs +4 -0
  38. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.mjs +240 -0
  39. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.mjs +201 -0
  40. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/style.less.mjs +4 -0
  41. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/index.mjs +399 -0
  42. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/style.less.mjs +4 -0
  43. package/dist/es/components/VLMAnnotationDetail/VlmModal/index.mjs +139 -0
  44. package/dist/es/components/VLMAnnotationDetail/VlmModal/style.less.mjs +4 -0
  45. package/dist/es/components/VLMAnnotationDetail/index.mjs +446 -0
  46. package/dist/es/components/VLMAnnotationDetail/style.less.mjs +4 -0
  47. package/dist/es/constant.mjs +3 -3
  48. package/dist/es/createVlmtasetAnnotation/index.mjs +131 -0
  49. package/dist/es/featuresConfig.mjs +13 -9
  50. package/dist/es/index.mjs +11 -7
  51. package/dist/lib/index.js +4 -3
  52. package/dist/src/DatasetContext/index.d.ts +2 -0
  53. package/dist/src/components/Iconfont/font_4439177_tgvowh6bmlb.d.ts +0 -0
  54. package/dist/src/components/PicZipImportModal/config.d.ts +20 -0
  55. package/dist/src/components/VLMAnnotation/ImageAnnotationDebugger.d.ts +4 -0
  56. package/dist/src/components/VLMAnnotation/RegionItem.d.ts +4 -0
  57. package/dist/src/components/VLMAnnotation/TextAnnotationPanel.d.ts +4 -0
  58. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.d.ts +12 -0
  59. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.d.ts +38 -0
  60. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.d.ts +18 -0
  61. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.d.ts +7 -0
  62. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.d.ts +13 -0
  63. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +21 -0
  64. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +31 -0
  65. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.d.ts +11 -0
  66. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +28 -0
  67. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.d.ts +13 -0
  68. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +37 -0
  69. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.d.ts +12 -0
  70. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +15 -0
  71. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.d.ts +32 -0
  72. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.d.ts +25 -0
  73. package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +4 -0
  74. package/dist/src/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.d.ts +32 -0
  75. package/dist/src/components/VLMAnnotation/components/DragButton.d.ts +7 -0
  76. package/dist/src/components/VLMAnnotation/components/FitToScreenButton.d.ts +6 -0
  77. package/dist/src/components/VLMAnnotation/components/RectangleButton.d.ts +7 -0
  78. package/dist/src/components/VLMAnnotation/components/Toolbar.d.ts +4 -0
  79. package/dist/src/components/VLMAnnotation/components/ZoomControls.d.ts +4 -0
  80. package/dist/src/components/VLMAnnotation/constants.d.ts +97 -0
  81. package/dist/src/components/VLMAnnotation/index.d.ts +6 -0
  82. package/dist/src/components/VLMAnnotation/types.d.ts +172 -0
  83. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.d.ts +14 -0
  84. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/ImageDetail/index.d.ts +16 -0
  85. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/OCRBoxMaker/LabelEditorInput.d.ts +12 -0
  86. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/OCRBoxMaker/LabelEditorItem.d.ts +21 -0
  87. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/OCRBoxMaker/LableEditor.d.ts +16 -0
  88. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/OCRBoxMaker/index.d.ts +19 -0
  89. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.d.ts +12 -0
  90. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.d.ts +12 -0
  91. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/index.d.ts +12 -0
  92. package/dist/src/components/VLMAnnotationDetail/VlmModal/index.d.ts +16 -0
  93. package/dist/src/components/VLMAnnotationDetail/index.d.ts +6 -0
  94. package/dist/src/constant.d.ts +1 -1
  95. package/dist/src/createVlmtasetAnnotation/index.d.ts +16 -0
  96. package/dist/src/featuresConfig.d.ts +4 -0
  97. package/dist/src/index.d.ts +3 -0
  98. package/package.json +2 -2
@@ -15,6 +15,8 @@ interface DatasetDetails {
15
15
  cvforceModelService?: ModelServiceApi;
16
16
  aiShop?: AIShopApi;
17
17
  };
18
+ token?: string;
19
+ apiUrl?: string;
18
20
  featuresConfig?: FeaturesConfig;
19
21
  }
20
22
  declare const DatasetContext: import('react').Context<DatasetDetails>;
@@ -0,0 +1,20 @@
1
+ export interface ImportConfig {
2
+ maxImageSize: number;
3
+ labeledExampleKey: string;
4
+ unlabeledExampleKey: string;
5
+ labelFormat?: 'json' | 'jsonl';
6
+ zipUploadTexts: {
7
+ labeled: {
8
+ description: string[];
9
+ };
10
+ unlabeled: {
11
+ description: string[];
12
+ };
13
+ };
14
+ }
15
+ /**
16
+ * 根据数据集类型获取导入配置
17
+ * @param markType 标注类型
18
+ * @returns 导入配置
19
+ */
20
+ export declare const getImportConfig: (markType?: string) => ImportConfig;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { ImageAnnotationDebuggerProps } from './types';
3
+ declare const ImageAnnotationDebugger: React.FC<ImageAnnotationDebuggerProps>;
4
+ export default ImageAnnotationDebugger;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { RegionItemProps } from './types';
3
+ declare const RegionItem: React.FC<RegionItemProps>;
4
+ export default RegionItem;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { TextAnnotationPanelProps } from './types';
3
+ declare const TextAnnotationPanel: React.FC<TextAnnotationPanelProps>;
4
+ export default TextAnnotationPanel;
@@ -0,0 +1,12 @@
1
+ import { fabric } from 'fabric';
2
+ interface UseCanvasDragParams {
3
+ canvas: fabric.Canvas | undefined;
4
+ draggable: boolean;
5
+ drawingMode: boolean;
6
+ }
7
+ /**
8
+ * Hook for managing canvas drag functionality
9
+ * @param params - Canvas drag configuration parameters
10
+ */
11
+ export declare const useCanvasDrag: ({ canvas, draggable, drawingMode, }: UseCanvasDragParams) => void;
12
+ export {};
@@ -0,0 +1,38 @@
1
+ import { fabric } from 'fabric';
2
+ import { VLMSample, Region } from '../../types';
3
+ interface UseCanvasSetupParams {
4
+ sample: VLMSample | undefined;
5
+ image: fabric.Image | undefined;
6
+ onImageLoad?: VoidFunction;
7
+ canvasRef: React.MutableRefObject<HTMLCanvasElement | null>;
8
+ containerRef: React.MutableRefObject<HTMLDivElement | null>;
9
+ canvasInitializedRef: React.MutableRefObject<boolean>;
10
+ bgImagePositionRef: React.MutableRefObject<{
11
+ left: number;
12
+ top: number;
13
+ }>;
14
+ bgImageSizeRef: React.MutableRefObject<{
15
+ width: number;
16
+ height: number;
17
+ }>;
18
+ rectMapRef: React.MutableRefObject<Map<fabric.Rect, Region>>;
19
+ updateTextLayersRef: React.MutableRefObject<((rect: fabric.Rect, region: Region) => void) | null>;
20
+ onRectPositionUpdated?: (scale: number) => void;
21
+ setCanvas: React.Dispatch<React.SetStateAction<fabric.Canvas | undefined>>;
22
+ setImage: React.Dispatch<React.SetStateAction<fabric.Image | undefined>>;
23
+ setScale: React.Dispatch<React.SetStateAction<number>>;
24
+ setBgImagePosition: React.Dispatch<React.SetStateAction<{
25
+ left: number;
26
+ top: number;
27
+ }>>;
28
+ setLoading: React.Dispatch<React.SetStateAction<boolean>>;
29
+ }
30
+ /**
31
+ * Hook for canvas setup and image initialization
32
+ * @param params - Canvas setup configuration parameters
33
+ * @returns updateCanvas function to update canvas and image positioning
34
+ */
35
+ export declare const useCanvasSetup: ({ sample, image, onImageLoad, canvasRef, containerRef, canvasInitializedRef, bgImagePositionRef, bgImageSizeRef, rectMapRef, updateTextLayersRef, onRectPositionUpdated, setCanvas, setImage, setScale, setBgImagePosition, setLoading, }: UseCanvasSetupParams) => {
36
+ updateCanvas: () => void;
37
+ };
38
+ export {};
@@ -0,0 +1,18 @@
1
+ import { fabric } from 'fabric';
2
+ interface UseCanvasZoomParams {
3
+ canvas: fabric.Canvas | undefined;
4
+ setScale: React.Dispatch<React.SetStateAction<number>>;
5
+ isZoomingRef: React.MutableRefObject<boolean>;
6
+ }
7
+ /**
8
+ * Hook for managing canvas zoom functionality
9
+ * @param params - Canvas zoom configuration parameters
10
+ * @returns zoom function
11
+ */
12
+ export declare const useCanvasZoom: ({ canvas, setScale, isZoomingRef, }: UseCanvasZoomParams) => {
13
+ zoom: (delta: number, point?: {
14
+ x: number;
15
+ y: number;
16
+ }) => void;
17
+ };
18
+ export {};
@@ -0,0 +1,7 @@
1
+ import { Region } from '../../types';
2
+ /**
3
+ * Hook for cropping region image from the original image
4
+ * @param imageUrl - URL of the original image
5
+ * @returns Function to crop region image and return base64 string
6
+ */
7
+ export declare const useCropRegionImage: (imageUrl: string | undefined) => (region: Region) => Promise<string | undefined>;
@@ -0,0 +1,13 @@
1
+ import { fabric } from 'fabric';
2
+ interface UseDeleteControlParams {
3
+ performDelete: (targetRect: fabric.Rect) => void;
4
+ }
5
+ /**
6
+ * Hook for creating delete control
7
+ * @param params - Delete control configuration parameters
8
+ * @returns createDeleteControl function
9
+ */
10
+ export declare const useDeleteControl: ({ performDelete, }: UseDeleteControlParams) => {
11
+ createDeleteControl: () => fabric.Control;
12
+ };
13
+ export {};
@@ -0,0 +1,21 @@
1
+ import { fabric } from 'fabric';
2
+ import { Region } from '../../types';
3
+ interface UseDeleteRegionParams {
4
+ canvas: fabric.Canvas | undefined;
5
+ onRegionChange?: (region: Region | null, action: 'create' | 'update' | 'delete') => void;
6
+ updateRegionNames: () => void;
7
+ rectMapRef: React.MutableRefObject<Map<fabric.Rect, Region>>;
8
+ textLayersMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Rect[]>>;
9
+ textLayoutContentMapRef: React.MutableRefObject<Map<fabric.Rect, string>>;
10
+ regionNameTextMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Text>>;
11
+ ocrLoadingIconMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Group>>;
12
+ }
13
+ /**
14
+ * Hook for managing region deletion functionality
15
+ * @param params - Delete region configuration parameters
16
+ * @returns performDelete function
17
+ */
18
+ export declare const useDeleteRegion: ({ canvas, onRegionChange, updateRegionNames, rectMapRef, textLayersMapRef, textLayoutContentMapRef, regionNameTextMapRef, ocrLoadingIconMapRef, }: UseDeleteRegionParams) => {
19
+ performDelete: (targetRect: fabric.Rect) => void;
20
+ };
21
+ export {};
@@ -0,0 +1,31 @@
1
+ import { fabric } from 'fabric';
2
+ import { Region, VLMLabel } from '../../types';
3
+ interface UseDrawingModeParams {
4
+ canvas: fabric.Canvas | undefined;
5
+ drawingMode: boolean;
6
+ draggable: boolean;
7
+ setDrawingMode: (mode: boolean) => void;
8
+ canvasToImageCoords: (canvasX: number, canvasY: number) => {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ labelDefinitions?: VLMLabel[];
13
+ onChange?: (labels: Region[]) => void;
14
+ cropRegionImage: (region: Region) => Promise<string | undefined>;
15
+ updateRegionShapeAndImage: (rect: fabric.Rect) => void;
16
+ performOCRIfNeeded: (region: Region, action: 'create' | 'update') => Promise<void>;
17
+ createDeleteControl: () => fabric.Control;
18
+ updateRegionNameText: (rect: fabric.Rect, region: Region) => void;
19
+ onRegionChange?: (region: Region | null, action: 'create' | 'update' | 'delete') => void;
20
+ onRegionSelect?: (region: Region | null) => void;
21
+ rectMapRef: React.MutableRefObject<Map<fabric.Rect, Region>>;
22
+ }
23
+ /**
24
+ * Hook for managing drawing mode (rectangle drawing functionality)
25
+ * @param params - Drawing mode configuration parameters
26
+ * @returns stopDraw function to stop drawing
27
+ */
28
+ export declare const useDrawingMode: ({ canvas, drawingMode, draggable, setDrawingMode, canvasToImageCoords, labelDefinitions, onChange, cropRegionImage, updateRegionShapeAndImage, performOCRIfNeeded, createDeleteControl, updateRegionNameText, onRegionChange, onRegionSelect, rectMapRef, }: UseDrawingModeParams) => {
29
+ stopDraw: () => void;
30
+ };
31
+ export {};
@@ -0,0 +1,11 @@
1
+ import { fabric } from 'fabric';
2
+ import { Region } from '../../types';
3
+ /**
4
+ * Hook for managing OCR loading icon animation
5
+ * @param canvas - Fabric.js canvas instance
6
+ * @returns Object containing updateOCRLoadingIcon function and ocrLoadingIconMapRef
7
+ */
8
+ export declare const useOCRLoadingIcon: (canvas: fabric.Canvas | undefined) => {
9
+ updateOCRLoadingIcon: (rect: fabric.Rect, region: Region, show: boolean) => void;
10
+ ocrLoadingIconMapRef: import('react').RefObject<Map<fabric.Rect, fabric.Group>>;
11
+ };
@@ -0,0 +1,28 @@
1
+ import { fabric } from 'fabric';
2
+ import { Region } from '../../types';
3
+ interface UseOCRRecognitionParams {
4
+ ocrRecognize?: (image: string) => Promise<Array<{
5
+ bbox: [number, number][];
6
+ content: string;
7
+ no: number;
8
+ score: number;
9
+ type: string;
10
+ }>>;
11
+ onChange?: (labels: Region[]) => void;
12
+ updateTextLayers: (rect: fabric.Rect, region: Region) => void;
13
+ canvas: fabric.Canvas | undefined;
14
+ updateOCRLoadingIcon: (rect: fabric.Rect, region: Region, show: boolean) => void;
15
+ rectMapRef: React.MutableRefObject<Map<fabric.Rect, Region>>;
16
+ textLayersMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Rect[]>>;
17
+ textLayoutContentMapRef: React.MutableRefObject<Map<fabric.Rect, string>>;
18
+ }
19
+ /**
20
+ * Hook for managing OCR recognition logic
21
+ * @param params - OCR recognition configuration parameters
22
+ * @returns performOCRIfNeeded function and ocrRecognizingRef
23
+ */
24
+ export declare const useOCRRecognition: ({ ocrRecognize, onChange, updateTextLayers, canvas, updateOCRLoadingIcon, rectMapRef, textLayersMapRef, textLayoutContentMapRef, }: UseOCRRecognitionParams) => {
25
+ performOCRIfNeeded: (region: Region, action: "create" | "update") => Promise<void>;
26
+ ocrRecognizingRef: import('react').RefObject<Set<string>>;
27
+ };
28
+ export {};
@@ -0,0 +1,13 @@
1
+ import { fabric } from 'fabric';
2
+ interface UseRegionHoverParams {
3
+ canvas: fabric.Canvas | undefined;
4
+ drawingMode: boolean;
5
+ draggable: boolean;
6
+ textLayersMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Rect[]>>;
7
+ }
8
+ /**
9
+ * Hook for managing region hover effects
10
+ * @param params - Region hover configuration parameters
11
+ */
12
+ export declare const useRegionHover: ({ canvas, drawingMode, draggable, textLayersMapRef, }: UseRegionHoverParams) => void;
13
+ export {};
@@ -0,0 +1,37 @@
1
+ import { fabric } from 'fabric';
2
+ import { VLMSample, Region } from '../../types';
3
+ interface UseRegionLoaderParams {
4
+ canvas: fabric.Canvas | undefined;
5
+ sample: VLMSample | undefined;
6
+ image: fabric.Image | undefined;
7
+ bgImagePosition: {
8
+ left: number;
9
+ top: number;
10
+ };
11
+ canvasInitializedRef: React.MutableRefObject<boolean>;
12
+ bgImagePositionRef: React.MutableRefObject<{
13
+ left: number;
14
+ top: number;
15
+ }>;
16
+ sampleRef: React.MutableRefObject<VLMSample | undefined>;
17
+ labelsLoadedRef: React.MutableRefObject<boolean>;
18
+ rectMapRef: React.MutableRefObject<Map<fabric.Rect, Region>>;
19
+ textLayersMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Rect[]>>;
20
+ textLayoutContentMapRef: React.MutableRefObject<Map<fabric.Rect, string>>;
21
+ regionNameTextMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Text>>;
22
+ ocrLoadingIconMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Group>>;
23
+ imageToCanvasCoords: (imageX: number, imageY: number) => {
24
+ x: number;
25
+ y: number;
26
+ };
27
+ updateRegionShapeAndImage: (rect: fabric.Rect) => void;
28
+ createDeleteControl: () => fabric.Control;
29
+ updateRegionNameText: (rect: fabric.Rect, region: Region) => void;
30
+ updateTextLayers: (rect: fabric.Rect, region: Region) => void;
31
+ }
32
+ /**
33
+ * Hook for loading labels from sample.labels
34
+ * @param params - Region loader configuration parameters
35
+ */
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;
37
+ export {};
@@ -0,0 +1,12 @@
1
+ import { fabric } from 'fabric';
2
+ import { Region } from '../../types';
3
+ /**
4
+ * Hook for managing region name text labels
5
+ * @param canvas - Fabric.js canvas instance
6
+ * @param ocrLoadingIconMapRef - Reference to OCR loading icon map (for updating scan line position)
7
+ * @returns Object containing updateRegionNameText function and regionNameTextMapRef
8
+ */
9
+ export declare const useRegionNameText: (canvas: fabric.Canvas | undefined) => {
10
+ updateRegionNameText: (rect: fabric.Rect, region: Region) => void;
11
+ regionNameTextMapRef: import('react').RefObject<Map<fabric.Rect, fabric.Text>>;
12
+ };
@@ -0,0 +1,15 @@
1
+ import { fabric } from 'fabric';
2
+ import { Region } from '../../types';
3
+ interface UseRegionSelectionParams {
4
+ canvas: fabric.Canvas | undefined;
5
+ onRegionSelect?: (region: Region | null) => void;
6
+ createDeleteControl: () => fabric.Control;
7
+ textLayersMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Rect[]>>;
8
+ rectMapRef: React.MutableRefObject<Map<fabric.Rect, Region>>;
9
+ }
10
+ /**
11
+ * Hook for managing region selection state
12
+ * @param params - Region selection configuration parameters
13
+ */
14
+ export declare const useRegionSelection: ({ canvas, onRegionSelect, createDeleteControl, textLayersMapRef, rectMapRef, }: UseRegionSelectionParams) => void;
15
+ export {};
@@ -0,0 +1,32 @@
1
+ import { fabric } from 'fabric';
2
+ import { Region } from '../../types';
3
+ interface UseRegionUpdateParams {
4
+ canvas: fabric.Canvas | undefined;
5
+ image: fabric.Image | undefined;
6
+ draggable: boolean;
7
+ canvasToImageCoords: (canvasX: number, canvasY: number) => {
8
+ x: number;
9
+ y: number;
10
+ };
11
+ imageToCanvasCoords: (imageX: number, imageY: number) => {
12
+ x: number;
13
+ y: number;
14
+ };
15
+ cropRegionImage: (region: Region) => Promise<string | undefined>;
16
+ onChange?: (labels: Region[]) => void;
17
+ onRegionChange?: (region: Region | null, action: 'create' | 'update' | 'delete') => void;
18
+ performOCRIfNeeded: (region: Region, action: 'create' | 'update') => Promise<void>;
19
+ updateTextLayers: (rect: fabric.Rect, region: Region) => void;
20
+ rectMapRef: React.MutableRefObject<Map<fabric.Rect, Region>>;
21
+ regionNameTextMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Text>>;
22
+ ocrLoadingIconMapRef: React.MutableRefObject<Map<fabric.Rect, fabric.Group>>;
23
+ }
24
+ /**
25
+ * Hook for updating region shape and image
26
+ * @param params - Region update configuration parameters
27
+ * @returns updateRegionShapeAndImage function to update region shape and crop image
28
+ */
29
+ export declare const useRegionUpdate: ({ canvas, image, draggable, canvasToImageCoords, imageToCanvasCoords, cropRegionImage, onChange, onRegionChange, performOCRIfNeeded, updateTextLayers, rectMapRef, regionNameTextMapRef, ocrLoadingIconMapRef, }: UseRegionUpdateParams) => {
30
+ updateRegionShapeAndImage: (rect: fabric.Rect) => void;
31
+ };
32
+ export {};
@@ -0,0 +1,25 @@
1
+ import { fabric } from 'fabric';
2
+ import { Region, VLMLabel } from '../../types';
3
+ interface UseTextLayoutsParams {
4
+ canvas: fabric.Canvas | undefined;
5
+ imageToCanvasCoords: (imageX: number, imageY: number) => {
6
+ x: number;
7
+ y: number;
8
+ };
9
+ activeLabelValue?: {
10
+ label: VLMLabel;
11
+ region: Region;
12
+ } | null;
13
+ onAppendTextToActive?: (text: string) => void;
14
+ }
15
+ /**
16
+ * Hook for managing text layout rectangles (OCR recognition results)
17
+ * @param params - Text layouts configuration parameters
18
+ * @returns Object containing updateTextLayers function and refs
19
+ */
20
+ export declare const useTextLayouts: ({ canvas, imageToCanvasCoords, activeLabelValue, onAppendTextToActive, }: UseTextLayoutsParams) => {
21
+ updateTextLayers: (rect: fabric.Rect, region: Region) => void;
22
+ textLayersMapRef: import('react').RefObject<Map<fabric.Rect, fabric.Rect[]>>;
23
+ textLayoutContentMapRef: import('react').RefObject<Map<fabric.Rect, string>>;
24
+ };
25
+ export {};
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { VLMLabelMakerProps } from '../types';
3
+ declare const VLMLabelMaker: React.FC<VLMLabelMakerProps>;
4
+ export default VLMLabelMaker;
@@ -0,0 +1,32 @@
1
+ import { fabric } from 'fabric';
2
+ /**
3
+ * Convert canvas coordinates to image coordinates
4
+ * @param canvasX - X coordinate in canvas coordinate system
5
+ * @param canvasY - Y coordinate in canvas coordinate system
6
+ * @param canvas - Fabric.js canvas instance
7
+ * @param image - Fabric.js image instance
8
+ * @param bgImagePositionRef - Reference to background image position
9
+ * @returns Image coordinates { x, y }
10
+ */
11
+ export declare const canvasToImageCoords: (canvasX: number, canvasY: number, canvas: fabric.Canvas | undefined, image: fabric.Image | undefined, bgImagePositionRef: React.MutableRefObject<{
12
+ left: number;
13
+ top: number;
14
+ }>) => {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ /**
19
+ * Convert image coordinates to canvas coordinates
20
+ * @param imageX - X coordinate in image coordinate system
21
+ * @param imageY - Y coordinate in image coordinate system
22
+ * @param canvas - Fabric.js canvas instance
23
+ * @param bgImagePositionRef - Reference to background image position
24
+ * @returns Canvas coordinates { x, y }
25
+ */
26
+ export declare const imageToCanvasCoords: (imageX: number, imageY: number, canvas: fabric.Canvas | undefined, bgImagePositionRef: React.MutableRefObject<{
27
+ left: number;
28
+ top: number;
29
+ }>) => {
30
+ x: number;
31
+ y: number;
32
+ };
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ interface DragButtonProps {
3
+ active: boolean;
4
+ onClick: () => void;
5
+ }
6
+ declare const DragButton: React.FC<DragButtonProps>;
7
+ export default DragButton;
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ interface FitToScreenButtonProps {
3
+ onClick: () => void;
4
+ }
5
+ declare const FitToScreenButton: React.FC<FitToScreenButtonProps>;
6
+ export default FitToScreenButton;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ interface RectangleButtonProps {
3
+ active: boolean;
4
+ onClick: () => void;
5
+ }
6
+ declare const RectangleButton: React.FC<RectangleButtonProps>;
7
+ export default RectangleButton;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { ToolbarProps } from '../types';
3
+ declare const Toolbar: React.FC<ToolbarProps>;
4
+ export default Toolbar;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { ZoomControlsProps } from '../types';
3
+ declare const ZoomControls: React.FC<ZoomControlsProps>;
4
+ export default ZoomControls;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * VLMAnnotation 组件相关的常量配置
3
+ */
4
+ /** 最大缩放级别 */
5
+ export declare const MAX_ZOOM = 20;
6
+ /** 最小缩放级别 */
7
+ export declare const MIN_ZOOM = 0.1;
8
+ /** 缩放因子(滚轮缩放时使用) */
9
+ export declare const ZOOM_FACTOR = 0.999;
10
+ /** 缩放精度误差阈值(用于判断缩放值是否一致) */
11
+ export declare const ZOOM_PRECISION_ERROR = 0.01;
12
+ /** 缩放步长(按钮点击时的缩放增量,滚轮向上滚一下是 -100,向下滚一下是 100) */
13
+ export declare const ZOOM_STEP = 100;
14
+ /** 基础边框宽度(像素) */
15
+ export declare const BASE_STROKE_WIDTH = 2;
16
+ /** 矩形边框颜色 */
17
+ export declare const RECT_STROKE_COLOR = "#EAD4FF";
18
+ /** 选中矩形的填充色 */
19
+ export declare const SELECTED_RECT_FILL_COLOR = "rgba(156, 36, 242, 0.1)";
20
+ /** 悬停矩形的填充色(比选中时更淡) */
21
+ export declare const HOVER_RECT_FILL_COLOR = "rgba(156, 36, 242, 0.05)";
22
+ /** 透明填充色 */
23
+ export declare const TRANSPARENT_FILL = "transparent";
24
+ /** 临时矩形的填充色 */
25
+ export declare const TEMP_RECT_FILL_COLOR = "rgba(0, 0, 0, 0)";
26
+ /** 临时矩形的虚线样式 */
27
+ export declare const TEMP_RECT_STROKE_DASH_ARRAY: [number, number];
28
+ /** Canvas 容器类名 */
29
+ export declare const CANVAS_CONTAINER_CLASS = "vlm-label-maker-canvas";
30
+ /** 默认左侧最小宽度(像素) */
31
+ export declare const DEFAULT_MIN_LEFT_WIDTH = 300;
32
+ /** 默认左侧比例 */
33
+ export declare const DEFAULT_LEFT_RATIO = 0.7;
34
+ /** 默认最小比例 */
35
+ export declare const DEFAULT_MIN_RATIO = 0.05;
36
+ /** 默认最大比例 */
37
+ export declare const DEFAULT_MAX_RATIO = 0.95;
38
+ /** 默认形状类型 */
39
+ export declare const DEFAULT_SHAPE_TYPE: "rect";
40
+ /** 区域名称前缀 */
41
+ export declare const REGION_NAME_PREFIX = "\u533A\u57DF";
42
+ /** 默认区域名称 */
43
+ export declare const DEFAULT_REGION_NAME = "\u533A\u57DF1";
44
+ /** 区域名称字体族 */
45
+ export declare const REGION_NAME_FONT_FAMILY = "Arial, sans-serif";
46
+ /** 区域名称基础字体大小(像素) */
47
+ export declare const REGION_NAME_FONT_SIZE = 12;
48
+ /** 区域名称基础内边距(像素) */
49
+ export declare const REGION_NAME_PADDING = 4;
50
+ /** OCR 扫描线条基础高度(像素) */
51
+ export declare const OCR_SCAN_LINE_BASE_HEIGHT = 3;
52
+ /** OCR 扫描线条光晕层倍数 */
53
+ export declare const OCR_SCAN_LINE_GLOW_MULTIPLIER = 3;
54
+ /** OCR 扫描线条核心位置倍数 */
55
+ export declare const OCR_SCAN_LINE_CORE_POSITION_MULTIPLIER = 1.5;
56
+ /** OCR 扫描线条核心高度倍数 */
57
+ export declare const OCR_SCAN_LINE_CORE_HEIGHT_MULTIPLIER = 0.5;
58
+ /** OCR 扫描动画速度(每次移动的距离相对于标注框高度) */
59
+ export declare const OCR_SCAN_ANIMATION_SPEED = 0.008;
60
+ /** OCR 扫描线条光晕颜色 */
61
+ export declare const OCR_SCAN_LINE_GLOW_COLOR = "rgba(156, 36, 242, 0.2)";
62
+ /** OCR 扫描线条较亮层颜色 */
63
+ export declare const OCR_SCAN_LINE_BRIGHT_COLOR = "rgba(156, 36, 242, 0.5)";
64
+ /** OCR 扫描线条核心颜色 */
65
+ export declare const OCR_SCAN_LINE_CORE_COLOR = "#9C24F2";
66
+ /** 文本布局矩形框填充色 */
67
+ export declare const TEXT_LAYOUT_RECT_FILL_COLOR = "rgba(156, 36, 242, 0.2)";
68
+ /** 文本布局矩形框边框色 */
69
+ export declare const TEXT_LAYOUT_RECT_STROKE_COLOR = "rgba(156, 36, 242, 0.2)";
70
+ /** 文本布局矩形框 hover 边框色 */
71
+ export declare const TEXT_LAYOUT_RECT_HOVER_STROKE_COLOR = "rgba(156, 36, 242, 0.5)";
72
+ /** 文本布局矩形框点击反馈颜色 */
73
+ export declare const TEXT_LAYOUT_RECT_CLICK_FEEDBACK_COLOR = "rgba(0, 255, 0, 0.2)";
74
+ /** 文本布局矩形框视觉反馈延迟(毫秒) */
75
+ export declare const TEXT_LAYOUT_RECT_FEEDBACK_DELAY = 300;
76
+ /** 控制点颜色 */
77
+ export declare const CONTROL_POINT_COLOR = "#9C24F2";
78
+ /** 控制点大小(像素) */
79
+ export declare const CONTROL_POINT_SIZE = 6;
80
+ /** 删除图标大小(像素) */
81
+ export declare const DELETE_ICON_SIZE = 36;
82
+ /** 删除控件 X 轴偏移(像素) */
83
+ export declare const DELETE_CONTROL_OFFSET_X = 20;
84
+ /** 删除控件 Y 轴偏移(像素) */
85
+ export declare const DELETE_CONTROL_OFFSET_Y = 24;
86
+ /** 区域名称文本颜色 */
87
+ export declare const REGION_NAME_TEXT_COLOR = "#9C24F2";
88
+ /** 图片导出格式 */
89
+ export declare const IMAGE_EXPORT_FORMAT = "image/png";
90
+ /** 删除确认弹框标题 */
91
+ export declare const DELETE_MODAL_TITLE = "\u786E\u8BA4\u5220\u9664";
92
+ /** 删除确认弹框内容 */
93
+ export declare const DELETE_MODAL_CONTENT = "\u786E\u5B9A\u8981\u5220\u9664\u6B64\u6807\u6CE8\u533A\u57DF\u5417\uFF1F";
94
+ /** 删除确认弹框确定按钮文本 */
95
+ export declare const DELETE_MODAL_OK_TEXT = "\u786E\u5B9A";
96
+ /** 删除确认弹框取消按钮文本 */
97
+ export declare const DELETE_MODAL_CANCEL_TEXT = "\u53D6\u6D88";
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ import { VLMAnnotationProps, VLMSample } from './types';
3
+ export declare const convertTopLeftToCenter: (sample: VLMSample) => VLMSample;
4
+ export type { ShapeType, Shape, Region, VLMSample, VLMLabelType, VLMLabel, VLMAnnotationProps, } from './types';
5
+ declare const VLMAnnotation: React.FC<VLMAnnotationProps>;
6
+ export default VLMAnnotation;