Skip to content

Commit

Permalink
add face match demo
Browse files Browse the repository at this point in the history
  • Loading branch information
chenqinghe committed Jan 20, 2018
1 parent 715df6f commit 60dc1d4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 0 additions & 1 deletion example/vision/face/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ func Match() {
if err != nil {
panic(err)
}

fmt.Println(rs.ToString())
}
20 changes: 20 additions & 0 deletions example/vision/face/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions vision/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ 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
}
if size.Height > MaxSize || size.Height < MinSize || size.Width > MaxSize || size.Width < MinSize {
return nil, errors.New("image size is invalid")
}

reader := bytes.NewBuffer(imageContent)
reader := bytes.NewReader(imageContent)

return &Image{
Reader: reader,
Expand Down

0 comments on commit 60dc1d4

Please sign in to comment.