-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2dfan4.go
56 lines (44 loc) · 851 Bytes
/
2dfan4.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
package _2dfan4
import (
"github.com/dev6699/face/model"
"gocv.io/x/gocv"
)
type Model struct {
affineMatrix gocv.Mat
}
type Input struct {
Img gocv.Mat
BoundingBox model.BoundingBox
}
type Output struct {
FaceLandmark68 FaceLandmark68
FaceLandmark68Score float64
}
type FaceLandmark68 struct {
Data []gocv.Point2f
}
func (f *FaceLandmark68) ToLandmark5() []gocv.Point2f {
return []gocv.Point2f{
model.CalculateMean2f(f.Data[36:42]),
model.CalculateMean2f(f.Data[42:48]),
f.Data[30],
f.Data[48],
f.Data[54],
}
}
type TModel = model.Model[*Input, *Output]
var _ TModel = &Model{}
func NewFactory() func() TModel {
return func() TModel {
return New()
}
}
func New() *Model {
return &Model{}
}
func (m *Model) ModelName() string {
return "2dfan4"
}
func (m *Model) ModelVersion() string {
return "1"
}