forked from hybridgroup/gocv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
videoio_test.go
58 lines (45 loc) · 1.17 KB
/
videoio_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
package gocv
import (
"io/ioutil"
"path/filepath"
"testing"
)
func TestVideoCaptureFile(t *testing.T) {
vc, _ := VideoCaptureFile("images/small.mp4")
defer vc.Close()
if !vc.IsOpened() {
t.Error("Unable to open VideoCaptureFile")
}
if fw := vc.Get(VideoCaptureFrameWidth); int(fw) != 560 {
t.Errorf("Expected frame width property of 560.0 got %f", fw)
}
if fh := vc.Get(VideoCaptureFrameHeight); int(fh) != 320 {
t.Errorf("Expected frame height property of 320.0 got %f", fh)
}
vc.Set(VideoCaptureBrightness, 100.0)
vc.Grab(10)
img := NewMat()
defer img.Close()
vc.Read(img)
if img.Empty() {
t.Error("Unable to read VideoCaptureFile")
}
}
func TestVideoWriterFile(t *testing.T) {
dir, _ := ioutil.TempDir("", "gocvtests")
tmpfn := filepath.Join(dir, "test.avi")
img := IMRead("images/face-detect.jpg", IMReadColor)
if img.Empty() {
t.Error("Invalid read of Mat in VideoWriterFile test")
}
defer img.Close()
vw, _ := VideoWriterFile(tmpfn, "MJPG", 25, img.Cols(), img.Rows())
defer vw.Close()
if !vw.IsOpened() {
t.Error("Unable to open VideoWriterFile")
}
err := vw.Write(img)
if err != nil {
t.Error("Invalid Write() in VideoWriter")
}
}