forked from hybridgroup/gocv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtracking_test.go
52 lines (45 loc) · 1.05 KB
/
tracking_test.go
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
package contrib
import (
"gocv.io/x/gocv"
"image"
"testing"
)
func BaseTestTracker(t *testing.T, tracker Tracker, name string) {
if tracker == nil {
t.Error("TestTracker " + name + " should not be nil")
}
img := gocv.IMRead("../images/face.jpg", 1)
if img.Empty() {
t.Error("TestTracker " + name + " input img failed to load")
}
defer img.Close()
rect := image.Rect(250, 150, 250+200, 150+250)
init := tracker.Init(img, rect)
if !init {
t.Error("TestTracker " + name + " failed in Init")
}
_, ok := tracker.Update(img)
if !ok {
t.Error("TestTracker " + name + " lost object in Update")
}
}
func TestSingleTrackers(t *testing.T) {
tab := []struct {
name string
tracker Tracker
}{
{"MIL", NewTrackerMIL()},
{"Boosting", NewTrackerBoosting()},
{"MedianFlow", NewTrackerMedianFlow()},
{"TLD", NewTrackerTLD()},
{"KCF", NewTrackerKCF()},
{"MOSSE", NewTrackerMOSSE()},
{"CSRT", NewTrackerCSRT()},
}
for _, test := range tab {
func() {
defer test.tracker.Close()
BaseTestTracker(t, test.tracker, test.name)
}()
}
}