forked from hybridgroup/gocv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cuda_test.go
79 lines (60 loc) · 1.46 KB
/
cuda_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
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
package cuda
import (
"testing"
"gocv.io/x/gocv"
)
func TestNewGpuMat(t *testing.T) {
mat := NewGpuMat()
defer mat.Close()
if !mat.Empty() {
t.Error("New GpuMat should be empty")
}
}
func TestNewGpuMatFromMat(t *testing.T) {
mat := gocv.NewMat()
defer mat.Close()
gpumat := NewGpuMatFromMat(mat)
defer gpumat.Close()
if !gpumat.Empty() {
t.Error("New GpuMat should be empty")
}
}
func TestNewGpuMatFromMatWithSize(t *testing.T) {
mat := gocv.NewMatWithSize(100, 200, gocv.MatTypeCV32FC4)
defer mat.Close()
gpumat := NewGpuMatFromMat(mat)
defer gpumat.Close()
if gpumat.Empty() {
t.Error("New GpuMat should be not empty")
}
if gpumat.Rows() != 100 {
t.Error("incorrect number of rows for GpuMat")
}
if gpumat.Cols() != 200 {
t.Error("incorrect number of cols for GpuMat")
}
if gpumat.Type() != gocv.MatTypeCV32FC4 {
t.Error("incorrect type for GpuMat")
}
}
func TestNewGpuMatWithSize(t *testing.T) {
gpumat := NewGpuMatWithSize(100, 200, gocv.MatTypeCV32FC4)
defer gpumat.Close()
if gpumat.Empty() {
t.Error("New GpuMat should be not empty")
}
if gpumat.Rows() != 100 {
t.Error("incorrect number of rows for GpuMat")
}
if gpumat.Cols() != 200 {
t.Error("incorrect number of cols for GpuMat")
}
if gpumat.Type() != gocv.MatTypeCV32FC4 {
t.Error("incorrect type for GpuMat")
}
}
func TestGetCudaEnabledDeviceCount(t *testing.T) {
if GetCudaEnabledDeviceCount() < 1 {
t.Fatal("expected atleast one cuda enabled device")
}
}