From 60dc1d437cd14c31cb54d2f05eb11ef4752406dd Mon Sep 17 00:00:00 2001 From: chenqinghe Date: Sat, 20 Jan 2018 09:44:39 +0800 Subject: [PATCH] add face match demo --- example/vision/face/match.go | 1 - example/vision/face/readme.md | 20 ++++++++++++++++++++ vision/image.go | 4 ++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/example/vision/face/match.go b/example/vision/face/match.go index 4a5c9cc..605c28f 100644 --- a/example/vision/face/match.go +++ b/example/vision/face/match.go @@ -22,6 +22,5 @@ func Match() { if err != nil { panic(err) } - fmt.Println(rs.ToString()) } diff --git a/example/vision/face/readme.md b/example/vision/face/readme.md index 2cdb28a..0d28351 100644 --- a/example/vision/face/readme.md +++ b/example/vision/face/readme.md @@ -12,6 +12,26 @@ rs, err := client.DetectAndAnalysis( vision.MustFromFile("face.jpg"), options, ) +if err != nil { + panic(err) +} +fmt.Println(rs.ToString()) +``` + +- 人脸比对 +```Go +client := face.NewFaceClient(APIKEY, APISECRET) + +rs, err := client.Match( + vision.MustFromFile("p1.jpg"), + vision.MustFromFile("p2.jpg"), + map[string]interface{}{ + "ext_fields": "qualities", //返回质量信息,取值固定,目前支持qualities(质量检测)(对所有图片都会做改处理) + "image_liveness": "faceliveness,faceliveness", //返回的活体信息,“faceliveness,faceliveness” 表示对比对的两张图片都做活体检测;“,faceliveness” 表示对第一张图片不做活体检测、第二张图做活体检测;“faceliveness,” 表示对第一张图片做活体检测、第二张图不做活体检测; + "types": "7,7", + }, +) + if err != nil { panic(err) } diff --git a/vision/image.go b/vision/image.go index 68d1e84..c9e5174 100644 --- a/vision/image.go +++ b/vision/image.go @@ -42,7 +42,7 @@ func FromFile(file string) (*Image, error) { return nil, err } - size, err := getImageSize(bytes.NewBuffer(imageContent)) + size, err := getImageSize(bytes.NewReader(imageContent)) if err != nil { return nil, err } @@ -50,7 +50,7 @@ func FromFile(file string) (*Image, error) { return nil, errors.New("image size is invalid") } - reader := bytes.NewBuffer(imageContent) + reader := bytes.NewReader(imageContent) return &Image{ Reader: reader,