forked from windosx/face-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example1.go
66 lines (63 loc) · 1.74 KB
/
example1.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
package main
import (
"github.com/zhaojunliing/face-engine/v3/util"
)
var imageInfo = util.GetResizedImageInfo("./mask.jpg")
/*func main() {
// 激活SDK
if err := OnlineActivation("YourAppID", "YourSDKKey", "YourActiveCode"); err != nil {
fmt.Printf("%#v\n", err)
return
}
// 初始化引擎
engine, err := NewFaceEngine(DetectModeImage,
OrientPriority0,
10, // 4.0最大支持10个人脸
EnableFaceDetect|EnableFaceRecognition|EnableFace3DAngle|EnableLiveness|EnableIRLiveness|EnableAge|EnableGender|EnableMaskDetect|EnableFaceLandMark)
if err != nil {
fmt.Printf("%#v\n", err)
return
}
deviceInfo, err := GetActiveDeviceInfo()
if err != nil {
fmt.Printf("%#v\n", err)
}
fmt.Printf("设备信息:%s\n", deviceInfo)
// 检测人脸
info, err := engine.DetectFaces(imageInfo.Width, imageInfo.Height, ColorFormatBGR24, imageInfo.DataUInt8)
if err != nil {
fmt.Printf("%#v\n", err)
return
}
// 处理人脸数据
if err = engine.Process(imageInfo.Width, imageInfo.Height, ColorFormatBGR24, imageInfo.DataUInt8, info, EnableAge|EnableGender|EnableFace3DAngle|EnableLiveness|EnableMaskDetect|EnableFaceLandMark); err != nil {
fmt.Printf("%#v\n", err)
return
}
// 获取年龄
ageInfo, err := engine.GetAge()
if err != nil {
fmt.Printf("%#v\n", err)
return
}
fmt.Printf("ageInfo: %v\n", ageInfo)
// 获取口罩信息
maskInfo, err := engine.GetMask()
if err != nil {
fmt.Printf("%#v\n", err)
return
}
fmt.Printf("口罩信息:%#v\n", maskInfo)
// 获取额头点位
landMark, err := engine.GetFaceLandMarkInfo()
if err != nil {
fmt.Printf("%#v\n", err)
return
}
fmt.Printf("额头点位:%#v\n", landMark)
// 销毁引擎
if err = engine.Destroy(); err != nil {
fmt.Printf("%#v\n", err)
return
}
}*/