Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
chenqinghe committed Jan 23, 2018
2 parents 8e7bfaf + 2864e0c commit 35e038f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion example/vision/face/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func Match() {
rs, err := client.Match(
vision.MustFromFile("1.jpg"),
vision.MustFromFile("6.png"),
map[string]string{
map[string]interface{}{
"ext_fields": "qualities", //返回质量信息,取值固定,目前支持qualities(质量检测)(对所有图片都会做改处理)
"image_liveness": "faceliveness,faceliveness", //返回的活体信息,“faceliveness,faceliveness” 表示对比对的两张图片都做活体检测;“,faceliveness” 表示对第一张图片不做活体检测、第二张图做活体检测;“faceliveness,” 表示对第一张图片做活体检测、第二张图不做活体检测;
"types": "7,7",
Expand Down
14 changes: 3 additions & 11 deletions vision/face/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import (
"fmt"
"github.com/chenqinghe/baidu-ai-go-sdk/vision"
"github.com/imroc/req"
url2 "net/url"
"strings"
)

const (
FACE_MATCH_URL = "https://aip.baidubce.com/rest/2.0/face/v2/match"
)

func (fc *FaceClient) Match(img1, img2 *vision.Image, options map[string]string) (*FaceResponse, error) {
func (fc *FaceClient) Match(img1, img2 *vision.Image, options map[string]interface{}) (*FaceResponse, error) {
if err := fc.Auth(); err != nil {
return nil, err
}
Expand All @@ -23,19 +21,13 @@ func (fc *FaceClient) Match(img1, img2 *vision.Image, options map[string]string)
return nil, err
}

options["images"] = fmt.Sprintf("%s,%s", url2.QueryEscape(imgContent1), url2.QueryEscape(imgContent2))

body := ""
for k, v := range options {
body += fmt.Sprintf("%s=%s&", k, v)
}
body = strings.TrimRight(body, "&")
options["images"] = fmt.Sprintf("%s,%s", imgContent1, imgContent2)

header := req.Header{
"Content-Type": "application/x-www-form-urlencoded",
}
url := FACE_MATCH_URL + "?access_token=" + fc.AccessToken
resp, err := req.Post(url, header, body)
resp, err := req.Post(url, header, req.Param(options))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 35e038f

Please sign in to comment.