Unofficial golang library for Face++.
- Face
- Detect
- Compare
- Beautify
- Merge Face
package main
import (
"fmt"
"github.com/evalphobia/go-face-plusplus/config"
"github.com/evalphobia/go-face-plusplus/face"
)
func getFacesFromURL(url string) ([]face.Faces, error) {
conf := config.Config{
APIKey: "",
APISecret: "",
Debug: true,
}
svc, err := face.New(conf)
if err != nil {
return nil, err
}
resp, err:= svc.DetectByURL(
url,
face.WithReturnLandmark(face.ReturnLandmarkYES),
face.WithReturnAttributes(face.GetAllReturnAttributes()...))
if err != nil {
return nil, err
}
fmt.Printf("Face Count: %d\n", resp.FaceNum)
return resp.Faces, nil
}
package main
import (
"fmt"
"github.com/evalphobia/go-face-plusplus/config"
"github.com/evalphobia/go-face-plusplus/face"
)
func compareFacesFromURL(url1, url2 string) ([]face.Faces, []face.Faces, error) {
conf := config.Config{
APIKey: "",
APISecret: "",
Debug: true,
}
svc, err := face.New(conf)
if err != nil {
return nil, err
}
resp, err:= svc.CompareByURL(url1, url2)
if err != nil {
return nil, err
}
fmt.Printf("Compare Confidence: %f\n", resp.Confidence)
return resp.Faces1, resp.Faces2, nil
}
package main
import (
"flag"
"fmt"
"io/ioutil"
"github.com/evalphobia/go-face-plusplus/beautify"
"github.com/evalphobia/go-face-plusplus/config"
)
func main() {
var templateURL string
var mergeURL string
flag.StringVar(&templateURL, "url1", "", "set temaplte image url")
flag.StringVar(&mergeURL, "url2", "", "set merge image url")
flag.Parse()
conf := config.Config{
APIKey: "",
APISecret: "",
// Debug: true, // big base64 response data will show up in stdout.
}
svc, err := beautify.New(conf)
if err != nil {
panic(err)
}
resp, err := svc.MergeFace(beautify.MergeFaceRequest{
TemplateURL: templateURL,
MergeURL: mergeURL,
})
if err != nil {
panic(err)
}
img, err := resp.GetResultImage()
if err != nil {
panic(err)
}
fileName := "merge_face_example.jpg"
if err := ioutil.WriteFile(fileName, img, 0644); err != nil {
panic(err)
}
fmt.Printf("Success merge face! see: %s\n", fileName)
}
Name | Description |
---|---|
FACEPP_API_KEY |
API Key of Face++. |
FACEPP_API_SECRET |
API Secret of Face++. |