Skip to content

Commit

Permalink
更新readme
Browse files Browse the repository at this point in the history
  • Loading branch information
wuqingtao committed Dec 26, 2019
1 parent 471d6ac commit 0d3b38a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
7 changes: 4 additions & 3 deletions baidu/aip/client/error.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package client

import "encoding/json"

import "fmt"
import (
"encoding/json"
"fmt"
)

// RequestError 请求错误
type RequestError interface {
Expand Down
2 changes: 2 additions & 0 deletions baidu/aip/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package aip 当前实现部分人脸库管理的api
package aip
17 changes: 0 additions & 17 deletions baidu/aip/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,6 @@ func (a *AccessToken) Expired(n int64) bool {
return false
}

// IsExpired 是否过期, n的值表示提前多少秒刷新令牌
// func (a *AccessToken) IsExpired(n int64) bool {
// expires := time.Now().Unix() - a.RefreshTime
// if expires >= a.ExpiresIn {
// return true
// }
// if n >= a.ExpiresIn {
// return true
// } else if n < 60 { // 最少提前60秒刷新
// n = 60
// }
// if expires >= a.ExpiresIn-n {
// return true
// }
// return false
// }

var (
// ErrNotFound 不存在
ErrNotFound = errors.New("NotFound")
Expand Down
26 changes: 24 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
# baiduaip 实现人脸识别所使用的接口sdk

运行`go test`前, 在baidu/aip/client/testdata目录下创建`key.json`, 内容如下:
[![GoDoc](https://godoc.org/github.com/antlinker/baiduaip/baidu/aip?status.svg)](https://godoc.org/github.com/antlinker/baiduaip/baidu/aip)

```go
import (
"github.com/antlinker/baiduaip/baidu/aip/client"
)

func main() {
// InitBaiduFaceOptions 初始化百度人脸服务的客户端
func InitBaiduFaceOptions(opt *client.Option) {
client.Init(opt)
// ...
}
```
注: 运行`go test`前, 需要在baidu/aip/testdata目录下创建`key.json`和测试图片, 内容如下:
```json
{
"AppID": "APPID",
"APIKey": "APIKEY",
"SecretKey": "SECRETKEY"
}
```
```
```shell
ls ./baidu/aip/testdata

cp.jpeg EF2B8C2B8BCD43DA931B218759D59C22.jpeg key.json man4.jpg tom.jpeg
```

0 comments on commit 0d3b38a

Please sign in to comment.