@rockshin/react-image-annotation
Version:
An image annotation tool for ai project that manual annotation for images, easy to use!
107 lines (106 loc) • 2.46 kB
TypeScript
export interface AnnotatorImage {
id: string;
src: string;
width: number;
height: number;
type: string;
}
export interface IAnnotationEvent {
image: {
id: string;
};
annotation: Annotation;
}
export interface IOnDoneEvent {
annotations: Annotation[];
image: {
id: string;
src: string;
};
}
export interface IImageChangeEvent {
index: number;
image: {
id: string;
src: string;
};
}
export interface IImageLoadErrorEvent {
index: number;
image: {
id?: string;
src: string;
};
error: string;
}
export interface ImageAnnotationEditorProps {
images: {
id?: string;
src: string;
annotations: Annotation[];
}[];
initialImageIndex?: number;
tools?: {
eraser?: {
enabled?: boolean;
};
text?: {
enabled?: boolean;
};
};
outputTriggerOn?: {
created?: boolean;
changed?: boolean;
deleted?: boolean;
navigated?: boolean;
};
onDone?(result: IOnDoneEvent): void;
onAnnotationChange?(params: IAnnotationEvent): void;
onAnnotationCreated?(params: IAnnotationEvent): void;
onAnnotationDeleted?(params: IAnnotationEvent): void;
onImageChange?(params: IImageChangeEvent): void;
onImageLoadError?: (error: Error, image: {
id: string;
src: string;
index: number;
}) => void;
}
export interface Annotation {
id: string;
x: number;
y: number;
width: number;
height: number;
rotation?: number;
label?: string;
type?: string;
confidence?: number;
timestamp: number;
metadata?: {
createdBy?: string;
modifiedAt?: number;
color?: string;
notes?: string;
tags?: string[];
isVerified?: boolean;
version?: number;
};
}
export interface LoadImageParams {
imageIndex: number;
images: {
id?: string;
src: string;
annotations: Annotation[];
}[];
setIsLoading: (loading: boolean) => void;
setImageLoadError: (error: Error | null) => void;
setImage: (image: AnnotatorImage | null) => void;
setUsedNumbers: (numbers: Set<number>) => void;
setDeletedNumbers: (numbers: number[]) => void;
onImageLoadError?: (error: Error, image: {
id: string;
src: string;
index: number;
}) => void;
}