-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw.go
97 lines (80 loc) · 1.65 KB
/
draw.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
package cvpipe
import (
"image"
"image/color"
"gocv.io/x/gocv"
)
type putText struct {
text string
org image.Point
fontFace gocv.HersheyFont
fontScale float64
color color.RGBA
thickness int
}
func (p *putText) Apply(m *PipeMat) *PipeMat {
gocv.PutText(m.mat, p.text, p.org, p.fontFace, p.fontScale, p.color, p.thickness)
return m
}
func (p *putText) Name() string {
return "putText"
}
func NewPutText(text string, org image.Point, fontFace gocv.HersheyFont, fontScale float64, color color.RGBA, thickness int) Filter {
return &putText{
text: text,
org: org,
fontFace: fontFace,
fontScale: fontScale,
color: color,
thickness: thickness,
}
}
func (p *putText) Close() {
return
}
type line struct {
pt1 image.Point
pt2 image.Point
color color.RGBA
thickness int
}
func (l *line) Apply(m *PipeMat) *PipeMat {
gocv.Line(m.mat, l.pt1, l.pt2, l.color, l.thickness)
return m
}
func (l *line) Name() string {
return "line"
}
func NewLine(pt1, pt2 image.Point, color color.RGBA, thickness int) Filter {
return &line{
pt1: pt1,
pt2: pt2,
color: color,
thickness: thickness,
}
}
func (l *line) Close() {
return
}
type rectangle struct {
rect image.Rectangle
color color.RGBA
thickness int
}
func NewRectangle(r image.Rectangle, c color.RGBA, thickness int) Filter {
return &rectangle{
rect: r,
color: c,
thickness: thickness,
}
}
func (r *rectangle) Apply(m *PipeMat) *PipeMat {
gocv.Rectangle(m.mat, r.rect, r.color, r.thickness)
return m
}
func (r *rectangle) Name() string {
return "rectangle"
}
func (r *rectangle) Close() {
return
}