-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathapispec.ts
More file actions
220 lines (194 loc) · 6.46 KB
/
Copy pathapispec.ts
File metadata and controls
220 lines (194 loc) · 6.46 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import { provide } from 'vue';
import { AnnotationId, StringKeyObject } from 'vue-media-annotator/BaseAnnotation';
import { GroupData } from 'vue-media-annotator/Group';
import { use } from 'vue-media-annotator/provides';
import { TrackData } from 'vue-media-annotator/track';
import { Attribute } from 'vue-media-annotator/use/AttributeTypes';
import { CustomStyle } from 'vue-media-annotator/StyleManager';
import { AttributeTrackFilter } from 'vue-media-annotator/AttributeTrackFilterControls';
import { MultiCamDesktop } from 'platform/desktop/constants';
type DatasetType = 'image-sequence' | 'video' | 'multi' | 'large-image';
type MultiTrackRecord = Record<string, TrackData>;
type MultiGroupRecord = Record<string, GroupData>;
type SubType = 'stereo' | 'multicam' | null; // Additional type info used for UI display enabled pipelines
interface AnnotationSchema {
version: number;
tracks: MultiTrackRecord;
groups: MultiGroupRecord;
}
/**
* Variation on AnnotationSchema where annotations are lists
* instead of objects, used for convenience with pagination.
*/
interface AnnotationSchemaList {
version: number;
tracks: TrackData[];
groups: GroupData[];
sets: string[];
}
interface Pipe {
name: string;
pipe: string;
type: string;
folderId?: string;
ownerId?: string;
ownerLogin?: string;
}
interface Category {
description: string;
pipes: Pipe[];
}
interface TrainingConfigs {
configs: string[];
default: string;
}
type Pipelines = Record<string, Category>;
interface SaveDetectionsArgs {
tracks: {
delete: AnnotationId[];
upsert: TrackData[];
};
groups: {
delete: AnnotationId[];
upsert: GroupData[];
};
set?: string;
}
interface SaveAttributeArgs {
delete: string[];
upsert: Attribute[];
}
interface SaveAttributeTrackFilterArgs {
delete: string[];
upsert: AttributeTrackFilter[];
}
interface FrameImage {
url: string;
filename: string;
}
export interface MultiCamImportFolderArgs {
defaultDisplay: string; // In multicam the default camera to display
sourceList: Record<string, {
sourcePath: string;
trackFile: string;
}>; // path/track file per camera
calibrationFile?: string; // NPZ calibation matrix file or kwivier *.conf file
type: 'image-sequence' | 'video';
}
export interface MultiCamImportKeywordArgs {
defaultDisplay: string; // In multicam the default camera to display
sourcePath: string; // Base folder used for import, globList will filter folder
globList: Record<string, {
glob: string;
trackFile: string;
}>; // glob pattern for base folder
calibrationFile?: string; // NPZ calibation matrix file or kwiver *.conf file
type: 'image-sequence'; // Always image-sequence type for glob matching
}
export type MultiCamImportArgs = MultiCamImportFolderArgs | MultiCamImportKeywordArgs;
interface MultiCamMedia {
cameras: Record<string, {
type: DatasetType;
imageData: FrameImage[];
videoUrl: string;
}>;
defaultDisplay: string; // Default camera for displaying the MultiCamMedia
}
interface MediaImportResponse {
jsonMeta: {
originalImageFiles: string[];
};
globPattern: string;
mediaConvertList: string[];
}
/**
* The parts of metadata a user should be able to modify.
*/
interface DatasetMetaMutable {
customTypeStyling?: Record<string, CustomStyle>;
customGroupStyling?: Record<string, CustomStyle>;
confidenceFilters?: Record<string, number>;
attributes?: Readonly<Record<string, Attribute>>;
attributeTrackFilters?: Readonly<Record<string, AttributeTrackFilter>>;
}
const DatasetMetaMutableKeys = ['attributes', 'confidenceFilters', 'customTypeStyling', 'customGroupStyling', 'attributeTrackFilters'];
interface DatasetMeta extends DatasetMetaMutable {
id: Readonly<string>;
imageData: Readonly<FrameImage[]>;
videoUrl: Readonly<string | undefined>;
type: Readonly<DatasetType | 'multi'>;
fps: Readonly<number>; // this will become mutable in the future.
name: Readonly<string>;
createdAt: Readonly<string>;
originalFps?: Readonly<number>;
subType: Readonly<SubType>; // In future this could have stuff like IR/EO
multiCamMedia: Readonly<MultiCamMedia | null>;
multiCam: Readonly<MultiCamDesktop | null>;
//calibrationFile?: Readonly<string>;
}
interface Api {
getPipelineList(): Promise<Pipelines>;
runPipeline(itemId: string, pipeline: Pipe): Promise<unknown>;
deleteTrainedPipeline(pipeline: Pipe): Promise<void>;
exportTrainedPipeline(path: string, pipeline: Pipe): Promise<unknown>;
getTrainingConfigurations(): Promise<TrainingConfigs>;
runTraining(
folderIds: string[],
pipelineName: string,
config: string,
annotatedFramesOnly: boolean,
labelText?: string,
): Promise<unknown>;
loadMetadata(datasetId: string): Promise<DatasetMeta>;
loadDetections(datasetId: string, revision?: number, set?: string): Promise<AnnotationSchemaList>;
saveDetections(datasetId: string, args: SaveDetectionsArgs): Promise<unknown>;
saveMetadata(datasetId: string, metadata: DatasetMetaMutable): Promise<unknown>;
saveAttributes(datasetId: string, args: SaveAttributeArgs): Promise<unknown>;
saveAttributeTrackFilters(datasetId: string,
args: SaveAttributeTrackFilterArgs): Promise<unknown>;
// Non-Endpoint shared functions
openFromDisk(datasetType: DatasetType | 'bulk' | 'calibration' | 'annotation' | 'text' | 'zip' | 'stereoConfiguration', directory?: boolean):
Promise<{canceled?: boolean; filePaths: string[]; fileList?: File[]; root?: string}>;
getTiles?(itemId: string, projection?: string): Promise<StringKeyObject>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getTileURL?(itemId: string, x: number, y: number, level: number, query: Record<string, any>):
string;
importAnnotationFile(id: string, path: string, file?: File,
additive?: boolean, additivePrepend?: string, set?: string): Promise<boolean | string[]>;
}
const ApiSymbol = Symbol('api');
/**
* provideApi specifies an implementation of the data persistence interface
* for use in vue-web-common
* @param api an api implementation
*/
function provideApi(api: Api) {
provide(ApiSymbol, api);
}
function useApi() {
return use<Readonly<Api>>(ApiSymbol);
}
export {
provideApi,
useApi,
};
export {
AnnotationSchema,
Api,
DatasetMeta,
DatasetMetaMutable,
DatasetMetaMutableKeys,
DatasetType,
SubType,
FrameImage,
MultiTrackRecord,
MultiGroupRecord,
Pipe,
Pipelines,
SaveDetectionsArgs,
SaveAttributeArgs,
SaveAttributeTrackFilterArgs,
TrainingConfigs,
MultiCamMedia,
MediaImportResponse,
};