Skip to content

Commit 12ff9e8

Browse files
committed
Add small test for update with landmark
1 parent 342a3f0 commit 12ff9e8

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/test_binding.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,43 @@ function testAccuracyWithoutLandmark() {
9494
console.log("********************************")
9595

9696
assert.deepStrictEqual(predicted, groundTruth, "Unexpected value returned");
97+
}
98+
99+
function testKeepLandmark(){
100+
console.log("Running testKeepLandmark")
101+
const tracker = new sortnode.SortNode(3, 0.3);
102+
103+
let input = [
104+
[120, 240, 50, 70, 0.9, 23, 24, 25, 26, 27, 28, 29, 30],
105+
[220, 340, 60, 80, 0.92, 33, 34, 35, 36, 37, 38, 39, 40, 51, 52],
106+
[320, 340, 70, 90, 0.91, 23, 24, 25, 26, 27, 28, 29, 50],
107+
]
108+
109+
let input_2 = [
110+
[121, 242, 52, 71, 0.91, 123, 124, 125, 126, 127, 128, 129, 130],
111+
[222, 342, 61, 81, 0.93, 133, 134, 135, 136, 137, 138, 139, 140],
112+
[321, 344, 73, 91, 0.94, 123, 124, 125, 126, 127, 128, 129, 150, 31, 32],
113+
]
114+
115+
let t1 = Date.now()
116+
for (let i = 0; i < 500; i++) {
117+
let res = tracker.update(input)
118+
for (let i = 0; i < res.length; i++) {
119+
assert.deepStrictEqual(res[i].landmarks, input[i].slice(5, input[i].length), "Unexpected value returned")
120+
}
121+
122+
let res_2 = tracker.update(input_2)
123+
for (let i = 0; i < res_2.length; i++) {
124+
assert.deepStrictEqual(res_2[i].landmarks, input_2[i].slice(5, input_2[i].length), "Unexpected value returned")
125+
}
126+
}
127+
let t2 = Date.now()
128+
let time_span = (t2 - t1) / 1000
97129

130+
console.log("********************************")
131+
console.log(`Total tracking with landmarks took: ${time_span}s for ${1000} frames`)
132+
console.log(`FPS = ${1000 / time_span}`)
133+
console.log("********************************")
98134
}
99135

100136
function testInvalidParams() {
@@ -104,6 +140,7 @@ function testInvalidParams() {
104140

105141
assert.doesNotThrow(testBasic, undefined, "testBasic threw an expection");
106142
assert.doesNotThrow(testAccuracyWithoutLandmark, undefined, "testAccuracyWithoutLandmark threw an expection");
143+
assert.doesNotThrow(testKeepLandmark, undefined, "testKeepLandmark threw an expection");
107144
assert.throws(testInvalidParams, undefined, "testInvalidParams didn't throw");
108145

109146
console.log("Tests passed- everything looks OK!");

0 commit comments

Comments
 (0)