forked from opendatacam/node-moving-things-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTracker.spec.js
More file actions
104 lines (91 loc) · 2.28 KB
/
Copy pathTracker.spec.js
File metadata and controls
104 lines (91 loc) · 2.28 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
const Tracker = require('../tracker');
const detections = [
[
{
x: 0.688212,
y: 0.755398,
w: 0.026031,
h: 0.048941,
confidence: 16.5444,
name: 'object'
}
],
[], // This empty frame ensure that the object will be removed if fastDelete is enabled.
[
{
x: 0.686925,
y: 0.796403,
w: 0.028142,
h: 0.050919,
confidence: 25.7651,
name: 'object'
}
],
[
{
x: 0.686721,
y: 0.837579,
w: 0.027887,
h: 0.054398,
confidence: 34.285399999999996,
name: 'object'
}
],
[
{
x: 0.686436,
y: 0.877328,
w: 0.026603,
h: 0.058,
confidence: 18.104300000000002,
name: 'object'
}
]
];
describe('Tracker', function () {
beforeEach(function () {
Tracker.reset();
Tracker.setParams({
fastDelete: true,
unMatchedFramesTolerance: 5,
iouLimit: 0.05
});
detections.forEach((frame, frameNb) => {
Tracker.updateTrackedItemsWithNewFrame(frame, frameNb);
});
});
describe('reset', function () {
it('resets ItemTracker idDisplay', function () {
Tracker.reset();
Tracker.updateTrackedItemsWithNewFrame(detections[0], 0);
expect(Tracker.getJSONOfTrackedItems()[0].id).toBe(0);
});
});
describe('fast delete', function () {
it('removes items with fast delete', function () {
expect(Tracker.getJSONOfTrackedItems()[0].id).toBeGreaterThan(0);
});
it('keeps the item if fastDelete is disabled', function () {
Tracker.setParams({ fastDelete: false });
Tracker.reset();
detections.forEach((frame, frameNb) => {
Tracker.updateTrackedItemsWithNewFrame(frame, frameNb);
});
expect(Tracker.getJSONOfTrackedItems()[0].id).toBe(0);
});
});
describe('custom distance function', function() {
var distanceSpy;
beforeEach(function() {
distanceSpy = jasmine.createSpy('distance spy', Tracker.iouDistance);
Tracker.reset();
Tracker.setParams({ distanceFunc: distanceSpy });
detections.forEach((frame, frameNb) => {
Tracker.updateTrackedItemsWithNewFrame(frame, frameNb);
});
});
it('called the custom distance', function() {
expect(distanceSpy).toHaveBeenCalled();
});
});
});