-
Notifications
You must be signed in to change notification settings - Fork 2
/
createAnnotations.ts
54 lines (51 loc) · 1.43 KB
/
createAnnotations.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// ImageNet Annotation Tool - FE
// Copyright (c) 2022-present NAVER Corp.
// MIT License
import API from "@aws-amplify/api";
import { AnnotationVersion } from "@constants";
import { AnnotationsStateType } from "@stores";
export default async (
annotations: AnnotationsStateType,
extraData: {
annotatorID: string;
version: AnnotationVersion;
workerID?: string;
assignmentID?: string;
hitID?: string;
}
) => {
const { annotatorID, version, workerID, assignmentID, hitID } = extraData;
const body = {
annotations: annotations.map((annotation) => ({
selectedCount: annotation.selectedCount,
hoveredCount: annotation.hoveredCount,
selected: annotation.selected,
mousePoint: {
x: annotation.ratioX,
y: annotation.ratioY,
},
imagePosition: {
x: annotation.imageX,
y: annotation.imageY,
},
imageWidth: annotation.imageWidth,
imageHeight: annotation.imageHeight,
originalImageWidth: annotation.originalImageWidth,
originalImageHeight: annotation.originalImageHeight,
estimateTime: annotation.estimateTime,
mouseTracking: annotation.mouseTracking.map((point) => ({
x: point.x,
y: point.y,
})),
annotatorID,
workerID,
assignmentID,
hitID,
imageID: annotation.imageID as string,
version,
})),
};
await API.post("ImageNetAPI", "/api/annotations", {
body,
});
};