Repository navigation
Expand file tree
/
Copy pathSnapshot.ts
More file actions
46 lines (40 loc) · 1.73 KB
/
Copy pathSnapshot.ts
File metadata and controls
46 lines (40 loc) · 1.73 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
import { FrameClassification } from "./FrameClassification";
export interface SnapshotCriteria {
deviceId?: string;
/** Restrict to snapshots whose highest-scoring edge class is one of these. */
classificationLabel?: string | string[];
/**
* Inclusive upper bound on the edge NO_CAT score, 0..1. An upper bound is the
* useful direction: almost every snapshot is an empty tunnel scoring ~1.0, so
* capping NO_CAT is what leaves the frames worth looking at.
*/
maxClassificationNoCat?: number;
/** true: only scored snapshots; false: only snapshots still awaiting a backfill. */
hasClassification?: boolean;
}
export class Snapshot {
id?: number;
deviceId: string;
timestamp: Date;
/** Edge classification vector as reported by the device at snapshot time. */
frameClassification?: FrameClassification;
/** Highest-scoring class of `frameClassification`, denormalised for indexed filtering. */
classificationLabel?: string;
[key: string]: any; // Allow any additional properties
constructor(initObj: Partial<Snapshot> & Record<string, any>) {
this.id = initObj.id;
this.deviceId = initObj.deviceId!;
this.timestamp = new Date(initObj.timestamp!);
this.frameClassification = initObj.frameClassification;
this.classificationLabel = initObj.classificationLabel ?? initObj.frameClassification?.topLabel;
// Assign other properties from initObj to this instance
for (const key in initObj) {
if (initObj.hasOwnProperty(key) && !this.hasOwnProperty(key)) {
this[key] = initObj[key];
}
}
}
get unixtime() {
return Math.floor(this.timestamp.getTime() / 1000);
}
}