-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfaceDetector.go
More file actions
47 lines (40 loc) · 1021 Bytes
/
faceDetector.go
File metadata and controls
47 lines (40 loc) · 1021 Bytes
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
package GoDeepStack
import (
"fmt"
"github.com/aavgoust02/GoDeepStack/util"
)
type FaceDetector struct {
*AbstractDetector
confidence float64
ImagePath string
}
type Face struct {
XMax int `json:"x_max"`
YMax int `json:"y_max"`
XMin int `json:"x_min"`
Confidence float64 `json:"confidence"`
YMin int `json:"y_min"`
}
type Faces struct {
Predictions []Face `json:"predictions"`
Success bool `json:"success"`
}
func (fd *FaceDetector) Endpoint() string {
c := fd.AbstractDetector.Client
protocol := "http"
if c.SSL {
protocol = "https"
}
return fmt.Sprintf("%s://%s:%d/v1/vision/face", protocol, c.Addr, c.Port)
}
func (fd *FaceDetector) SetMinConfidence(confidence float64) *FaceDetector {
fd.confidence = confidence
return fd
}
func (fd *FaceDetector) Detect(imagePath string) *Faces {
files := util.NewEmptyFiles()
files.Files["image"] = imagePath
var result *Faces
fd.SendRequest(files, util.NewEmptyParameters(), &result)
return result
}