forked from hybridgroup/gocv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphoto_test.go
127 lines (105 loc) · 3.06 KB
/
photo_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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package gocv
import (
"image"
"testing"
)
func TestColorChange(t *testing.T) {
src := NewMatWithSize(20, 20, MatTypeCV8UC3)
defer src.Close()
dst := NewMat()
defer dst.Close()
mask := src.Clone()
defer mask.Close()
ColorChange(src, mask, &dst, 1.5, .5, .5)
if dst.Empty() || dst.Rows() != src.Rows() || dst.Cols() != src.Cols() {
t.Error("Invlalid ColorChange test")
}
}
func TestSeamlessClone(t *testing.T) {
src := NewMatWithSize(20, 20, MatTypeCV8UC3)
defer src.Close()
dst := NewMatWithSize(30, 30, MatTypeCV8UC3)
defer dst.Close()
blend := NewMatWithSize(dst.Rows(), dst.Cols(), dst.Type())
defer blend.Close()
mask := src.Clone()
defer mask.Close()
center := image.Point{dst.Cols() / 2, dst.Rows() / 2}
SeamlessClone(src, dst, mask, center, &blend, NormalClone)
if blend.Empty() || dst.Rows() != blend.Rows() || dst.Cols() != blend.Cols() {
t.Error("Invlalid SeamlessClone test")
}
}
func TestIlluminationChange(t *testing.T) {
src := NewMatWithSize(20, 20, MatTypeCV8UC3)
defer src.Close()
dst := NewMat()
defer dst.Close()
mask := src.Clone()
defer mask.Close()
IlluminationChange(src, mask, &dst, 0.2, 0.4)
if dst.Empty() || dst.Rows() != src.Rows() || dst.Cols() != src.Cols() {
t.Error("Invlalid IlluminationChange test")
}
}
func TestTextureFlattening(t *testing.T) {
src := NewMatWithSize(20, 20, MatTypeCV8UC3)
defer src.Close()
dst := NewMat()
defer dst.Close()
mask := src.Clone()
defer mask.Close()
TextureFlattening(src, mask, &dst, 30, 45, 3)
if dst.Empty() || dst.Rows() != src.Rows() || dst.Cols() != src.Cols() {
t.Error("Invlalid TextureFlattening test")
}
}
func TestFastNlMeansDenoisingColoredMultiWithParams(t *testing.T) {
var src [3]Mat
for i := 0; i < 3; i++ {
src[i] = NewMatWithSize(20, 20, MatTypeCV8UC3)
defer src[i].Close()
}
dst := NewMat()
defer dst.Close()
FastNlMeansDenoisingColoredMultiWithParams([]Mat{src[0], src[1], src[2]}, &dst, 1, 1, 3, 3, 7, 21)
if dst.Empty() || dst.Rows() != src[0].Rows() || dst.Cols() != src[0].Cols() {
t.Error("Invalid FastNlMeansDenoisingColoredMultiWithParams test")
}
}
func TestMergeMertens(t *testing.T) {
var src [3]Mat
for i := 0; i < 3; i++ {
src[i] = NewMatWithSize(20, 20, MatTypeCV8UC3)
defer src[i].Close()
}
dst := NewMat()
defer dst.Close()
mertens := NewMergeMertens()
defer mertens.Close()
mertens.Process([]Mat{src[0], src[1], src[2]}, &dst)
if dst.Empty() || dst.Rows() != src[0].Rows() || dst.Cols() != src[0].Cols() {
t.Error("Invalid TestMergeMertens test")
}
}
func TestNewAlignMTB(t *testing.T) {
var src [3]Mat
for i := 0; i < 3; i++ {
src[i] = NewMatWithSize(20, 20, MatTypeCV8UC3)
defer src[i].Close()
}
alignwtb := NewAlignMTB()
defer alignwtb.Close()
var dst []Mat
alignwtb.Process([]Mat{src[0], src[1], src[2]}, &dst)
sizedst := len(dst)
t.Logf(" Size Dst slice : %d ", sizedst)
if sizedst > 0 {
if dst[0].Empty() || dst[0].Rows() != src[0].Rows() || dst[0].Cols() != src[0].Cols() {
t.Error("Invalid TestNewAlignMTB test")
}
}
if sizedst <= 0 {
t.Error("Invalid TestNewAlignMTB test : empty result")
}
}