本文档即将废弃,请使用新版本接口:http://yf.jfgou.com:81/devdocs/OSR.md
(约定url采用RESTful API格式,域名:api.jfgou.com,服务名称:hsr,版本v1,操作内容:token)
Post方法:
act:
客户端调用,通过API服务端向萝卜头服务器请求鉴权。注意必须在https下才能鉴权,http下不允许鉴权
参数:
service_key 用户在萝卜头注册、开通人形检测服务的ServiceKey
返回结果:
范例:`{"ret":0, "msg":"", "token":"kwejrpoqawefjasdjfasdlfkj", "expired":1491374355 }`
ret 0正常返回,非0为错误值
msg 错误描述,ret为0时msg为空
token 字符串,后续人形检测是需要传入的令牌参数
expired unix格式时间,表示token过期时间,目前是24小时内有效
https://api.jfgou.com/hsr/v1/token_sign
Get、Post方法:
act:
客户端调用,通过API服务端向萝卜头服务器请求鉴权。与上面的token接口功能相同,但可在http协议下执行
参数:
service_key 用户在萝卜头注册、开通人形检测服务的ServiceKey
sign 用企业私钥签名ServiceKey的结果,萝卜头用企业上传的公钥和输入的service_key来校验。
返回结果:
范例:`{"ret":0, "msg":"", "token":"kwejrpoqawefjasdjfasdlfkj", "expired":1491374355 }`
ret 0正常返回,非0为错误值
msg 错误描述,ret为0时msg为空
token 字符串,后续人形检测是需要传入的令牌参数
expired unix格式时间,表示token过期时间,目前是5分钟内有效
https://api.jfgou.com/hsr/v1/hsr_detection
Post方法(enctype=“multipart/form-data”):
act:
客户端调用,请求分析图片。为了保证并发速度,该接口用http,不需要用https
参数:
token 通过https获取的token
file 背景或者目标图片文件,支持PNG、JPG格式,最大4M
返回结果:
范例:`{"ret":0,"msg":"ok","features":[{"person":{"coordinate":[382,190,562,434],"confidence":0.6668345332145691}},{"person":{"coordinate":[47,255,335,473],"confidence":0.43983975052833557}}]}`
ret 0正常返回,非0为错误值
msg 消息描述
features 特征组合,每一组代表检测出一个人形,范例中检测出了两个人形。person表示检测出人,coordinate表示人体在图像的矩形范围,依次为左上角X和Y坐标、右下角X和Y坐标,confidence表示置信度。
测试页面 http://apiyf.robotscloud.com/hsr/v2/test.html
Get、Post方法:
act:
客户端调用,通过API服务端向萝卜头服务器请求鉴权。注意必须在https下才能鉴权,http下不允许鉴权
参数:
service_key 用户在萝卜头注册、开通人形检测服务的ServiceKey
device_sn 设备序列号
service_code 在萝卜头注册的服务码
返回结果:
范例:`{"ret":0, "msg":"", "token":"kwejrpoqawefjasdjfasdlfkj", "expired":1491374355 }`
ret 0正常返回,非0为错误值
msg 错误描述,ret为0时msg为空
token 字符串,后续人形检测是需要传入的令牌参数
expired unix格式时间,表示token过期时间,目前是24小时内有效
https://api.jfgou.com/hsr/v2/hsr_detection
Post方法(enctype=“multipart/form-data”):
act:
客户端调用,请求分析图片。为了保证并发速度,该接口用http,不需要用https
参数:
token 通过https获取的token
file 背景或者目标图片文件,支持PNG、JPG格式,最大4M
返回结果:
范例:`{"ret":0,"msg":"ok","features":{"person":1,"cat":0,"dog":0}}`
ret 0正常返回,非0为错误值
msg 消息描述
features 检测结果,可检测出person、cat、dog等,1为检测到了,0为未检测到。
https://api.jfgou.com/hsr/v2/hsr_detection2
Post方法(enctype=“multipart/form-data”):
act:
合并了v2/token和v2/hsr_detection两个接口的功能
参数:
service_key 用户在萝卜头注册、开通人形检测服务的ServiceKey
device_sn 设备序列号
service_code 在萝卜头注册的服务码
file 背景或者目标图片文件,支持PNG、JPG格式,最大4M
go语言范例:
package main
import (
"bytes"
"fmt"
"io/ioutil"
"mime/multipart"
"net/http"
)
func main() {
var buff bytes.Buffer
writer := multipart.NewWriter(&buff)
writer.WriteField("service_key", "O86hXeNXTs7ZTSieX0jmA2JbhVNlGpaJ")
writer.WriteField("device_sn", "xxx")
writer.WriteField("service_code", "xxx")
w, _ := writer.CreateFormFile("file", "1r.jpg")
dat, err := ioutil.ReadFile("f:/1.jpg")
w.Write(dat)
writer.Close()
var client http.Client
resp, err := client.Post("https://api.jfgou.com/hsr/v2/hsr_detection2", writer.FormDataContentType(), &buff)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
data, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(data))
}
返回结果:
范例:`{"ret":0,"msg":"ok","features":{"person":1,"cat":0,"dog":0}}`
ret 0正常返回,非0为错误值
msg 消息描述
features 检测结果,可检测出person、cat、dog等,1为检测到了,0为未检测到。
https://api.jfgou.com/hsr/v1/face_check
Post方法:
act:
客户端调用,请求分析是不是符合人脸识别的图片。
参数:
token 通过https获取的token
file 背景或者目标图片文件,支持PNG、JPG格式,最大4M
返回结果:
范例:`{"ret":0,"msg":"ok","data":""}`
ret 0正常返回,非0为错误值
msg 消息描述
data 无数据,不起作用
https://api.jfgou.com/hsr/v1/face_extract_features
Post方法:
act:
客户端调用,分析上传的人脸图片提取特征值。
参数:
token 通过https获取的token
file 背景或者目标图片文件,支持PNG、JPG格式,最大4M
返回结果:
范例:`{"ret":0,"msg":"ok","features": [-0.026386105, -0.028243214, 0.0075532785, -0.076519154, -0.010262489, ...]}`
ret 0正常返回,非0为错误值
msg 消息描述
features 数组,人脸图片特征值
https://api.jfgou.com/hsr/v1/face_extract_comparefeatures
Post方法:
act:
客户端调用,分析上传的人脸图片与上传的人脸图片特征值对比人脸的相似度。
参数:
token 通过https获取的token
file 背景或者目标图片文件,支持PNG、JPG格式,最大4M
features 人脸图片特征值字符串(将特征值数组转换为逗号隔开的字符串),通过调用http://api.jfgou.com/hsr/v1/face_extract_features获得
返回结果:
范例:`{"ret":0,"msg":"ok","similarity": [0.99999999690224006]}`
ret 0正常返回,非0为错误值
msg 消息描述
similarity 数组,两张人脸图片的相似度
https://api.jfgou.com/hsr/v1/face_reg
Post方法:
act:
客户端调用,注册图片,可反复调用注册多张图片,目前最大支持5张,一次传一张。
参数:
token 通过https获取的token
face_id 人脸注册id,在系统中的唯一值,第一次调用传空值,系统返回一个随意字符串,第二次调用则用前面生成的值。
file 目标图片文件,支持PNG、JPG格式,最大4M。
返回结果:
范例:`{"ret":0,"msg":"ok","face_id": "dfasdfklasdjgasdkjoiwefajsdlfkasdfasdfasdfasdfasdf"}`
ret 0正常返回,非0为错误值
msg 消息描述
face_id 注册id,在系统中的唯一值
https://api.jfgou.com/hsr/v1/face_get_all
Post方法:
act:
客户端调用,注册图片。
参数:
token 通过https获取的token
face_id 人脸注册id,在系统中的唯一值
返回结果:
范例:`{"ret":0,"msg":"ok","count":3,"url_list":["http://1.jpg","http://1.jpg","http://1.jpg"]}`
ret 0正常返回,非0为错误值
msg 消息描述
count 图片个数
url_list 所有已注册的图片
https://api.jfgou.com/hsr/v1/face_del
Post方法:
act:
客户端调用,删除注册的图片。
参数:
token 通过https获取的token
face_id 人脸注册id,在系统中的唯一值
url http://1.jpg
返回结果:
范例:`{"ret":0,"msg":"ok"}`
ret 0正常返回,非0为错误值
msg 消息描述
https://api.jfgou.com/hsr/v1/face_compare
Post方法:
act:
客户端调用,与注册的图片对比。
参数:
token 通过https获取的token
file 目标图片文件,支持PNG、JPG格式,最大4M
face_id_list 人脸注册id,用英文逗号分隔,最多10个,如:aaaadfklasdjgasdkjoiwefajsdlfkasdfasdfasdfasdfasdf,bbbbdfklasdjgasdkjoiwefajsdlfkasdfasdfasdfasdfasdf,ccccdfklasdjgasdkjoiwefajsdlfkasdfasdfasdfasdfasdf
go语言范例:
package main
import (
"bytes"
"fmt"
"io/ioutil"
"mime/multipart"
"net/http"
)
func main() {
var buff bytes.Buffer
writer := multipart.NewWriter(&buff)
face_id_list := `9b4ykzssq8cyfnds46ksg9sv5tx6kevy,umq795jvu2y7iatgiim7zg5g9ns73fbw,ic6zq33ey7mjdp5ggm7rfb25eiseqpj3`
writer.WriteField("face_id_list", face_id_list)
writer.WriteField("token", "n2by7ZZHE0MTKyGJ7yOva3ZT8LQGH6PR")
w, _ := writer.CreateFormFile("file", "pic.jpg")
dat, err := ioutil.ReadFile("f:/3.jpg")
w.Write(dat)
writer.Close()
var client http.Client
resp, err := client.Post("https://apiyf.robotscloud.com/hsr/v1/face_compare", writer.FormDataContentType(), &buff)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
data, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(data))
}
返回结果:
范例:
{
"ret": 0,
"msg": "ok",
"similaritys": [
{
"face_id": "9b4ykzssq8cyfnds46ksg9sv5tx6kevy",
"similarity": 0
},
{
"face_id": "umq795jvu2y7iatgiim7zg5g9ns73fbw",
"similarity": 0.20662292552772493
},
{
"face_id": "ic6zq33ey7mjdp5ggm7rfb25eiseqpj3",
"similarity": 0.010478542506417318
}
]
}
ret 0正常返回,非0为错误值
msg 消息描述
similaritys 每个注册id的最高相似度
https://api.jfgou.com/hsr/v1/face_detection
Post方法:
act:
客户端调用,人脸检测,返回人脸坐标。
参数:
token 通过https获取的token
file 目标图片文件,支持PNG、JPG格式,最大4M
go语言范例:
package main
import (
"bytes"
"fmt"
"io/ioutil"
"mime/multipart"
"net/http"
)
func main() {
var buff bytes.Buffer
writer := multipart.NewWriter(&buff)
writer.WriteField("token", "Jkc2A0CmII5DP6Nzm1b4K5RLEFuHMlUI")
w, _ := writer.CreateFormFile("file", "pic.jpg")
dat, err := ioutil.ReadFile("f:/3.jpg")
w.Write(dat)
writer.Close()
var client http.Client
resp, err := client.Post("https://apiyf.robotscloud.com/hsr/v1/face_detection", writer.FormDataContentType(), &buff)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
data, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(data))
}
返回结果:
范例:
{
"ret": 0,
"msg": "ok",
"facefeatures": [
{
"face": {
"coordinate": [
472,
172,
532,
247
],
"confidence": 0.9987719655036926
}
},
{
"face": {
"coordinate": [
603,
208,
652,
270
],
"confidence": 0.996982991695404
}
},
{
"face": {
"coordinate": [
379,
220,
429,
284
],
"confidence": 0.9934282898902893
}
}
]
}
ret 0正常返回,非0为错误值
msg 消息描述
facefeatures 多张人脸的数据,coordinate是人脸坐标,依次为左上角X和Y坐标、右下角X和Y坐标,confidence是人脸置信度
https://apiyf.robotscloud.com/hsr/v1/detect_compare
Post方法:
act:
人形检测、人脸检测、人脸识别三合一接口
参数:
token 通过https获取的token
pic_url_list 需要被检测的图片。在公网的图片url全路径,如果有多张图片,用英文逗号分隔,每张图片最大4M
face_id_list 在萝卜头注册的人脸id,如果有多个id,用英文逗号分隔
go语言范例:
package main
import (
"bytes"
"fmt"
"io/ioutil"
"mime/multipart"
"net/http"
)
func main() {
var buff bytes.Buffer
writer := multipart.NewWriter(&buff)
pic_url_list := `http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/timg.jpg,http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/t2.jpg,http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/t3.jpg`
face_id_list := `9b4ykzssq8cyfnds46ksg9sv5tx6kevy,umq795jvu2y7iatgiim7zg5g9ns73fbw,ic6zq33ey7mjdp5ggm7rfb25eiseqpj3`
writer.WriteField("pic_url_list", pic_url_list)
writer.WriteField("face_id_list", face_id_list)
writer.WriteField("token", "4rgF3XnteCUx2Le7rokT6j8jyO3JNIxW")
writer.Close()
var client http.Client
resp, err := client.Post("https://apiyf.robotscloud.com/hsr/v1/detect_compare", writer.FormDataContentType(), &buff)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
data, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(data))
}
返回结果:
范例:
{
"ret": 0,
"msg": "ok",
"data": [
{
"pic_file": "http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/timg.jpg",
"human_detection": {
"ret": 0,
"msg": "ok",
"features": [
{
"person": {
"coordinate": [
0,
11,
554,
645
],
"confidence": 1.0651928186416626
}
}
]
},
"face_detection": {
"ret": 0,
"msg": "ok",
"features": [
{
"face": {
"coordinate": [
231,
87,
510,
440
],
"confidence": 0.9993162155151367
}
}
]
},
"similaritys": [
{
"face_id": "9b4ykzssq8cyfnds46ksg9sv5tx6kevy",
"similarity": 0.6538353411772075
},
{
"face_id": "umq795jvu2y7iatgiim7zg5g9ns73fbw",
"similarity": 0.01966740666296612
},
{
"face_id": "ic6zq33ey7mjdp5ggm7rfb25eiseqpj3",
"similarity": 0.9999999824186342
}
]
},
{
"pic_file": "http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/t2.jpg",
"human_detection": {
"ret": 0,
"msg": "ok",
"features": [
{
"person": {
"coordinate": [
115,
1,
513,
293
],
"confidence": 0.6171044707298279
}
}
]
},
"face_detection": {
"ret": 0,
"msg": "ok",
"features": [
{
"face": {
"coordinate": [
236,
19,
399,
220
],
"confidence": 0.9999334812164307
}
}
]
},
"similaritys": [
{
"face_id": "9b4ykzssq8cyfnds46ksg9sv5tx6kevy",
"similarity": 0.003175870626410295
},
{
"face_id": "umq795jvu2y7iatgiim7zg5g9ns73fbw",
"similarity": 1.000000023084873
},
{
"face_id": "ic6zq33ey7mjdp5ggm7rfb25eiseqpj3",
"similarity": 0.01966740161338813
}
]
},
{
"pic_file": "http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/t3.jpg",
"human_detection": {
"ret": 0,
"msg": "ok",
"features": [
{
"person": {
"coordinate": [
59,
50,
455,
298
],
"confidence": 0.4212017059326172
}
}
]
},
"face_detection": {
"ret": 0,
"msg": "ok",
"features": [
{
"face": {
"coordinate": [
229,
77,
368,
256
],
"confidence": 0.9985519051551819
}
}
]
},
"similaritys": [
{
"face_id": "9b4ykzssq8cyfnds46ksg9sv5tx6kevy",
"similarity": 1.0000000029210283
},
{
"face_id": "umq795jvu2y7iatgiim7zg5g9ns73fbw",
"similarity": 0.0031758294712535074
},
{
"face_id": "ic6zq33ey7mjdp5ggm7rfb25eiseqpj3",
"similarity": 0.6538354029810238
}
]
}
]
}
ret 0正常返回,非0为错误值
msg 消息描述
data 检测结果,每张图片与注册的face_id下的图片对比结果
{
"pic_file": 被检测的图片url,
"human_detection": {
"ret": 人形检测结果,0未正确,非0为检测失败,
"msg": 检测结果描述,
"features": [
{
"person": {
"coordinate": [
人形坐标,依次为左上角X和Y坐标、右下角X和Y坐标
],
"confidence": 人形置信度
}
}
]
},
"face_detection": {
"ret": 人脸检测结果,0未正确,非0为检测失败,
"msg": 检测结果描述,
"features": [
{
"face": {
"coordinate": [
人脸坐标,依次为左上角X和Y坐标、右下角X和Y坐标
],
"confidence": 人脸置信度
}
}
]
},
"similaritys": [
{
"face_id": 在萝卜头注册的人脸id,
"similarity": 上述pic_file指定待检测的公网图片与注册id下的图片相似度
},
{
"face_id": "umq795jvu2y7iatgiim7zg5g9ns73fbw",
"similarity": 0.01966740666296612
},
{
"face_id": "ic6zq33ey7mjdp5ggm7rfb25eiseqpj3",
"similarity": 0.9999999824186342
}
]
}
https://apiyf.robotscloud.com/hsr/v1/detect_compare_fast
Post方法:
act:
人形检测、人脸检测、人脸识别三合一接口,对上面的/hsr/v1/detect_compare改进
参数:
token 通过https获取的token
pic_url_list 需要被检测的图片。在公网的图片url全路径,如果有多张图片,用英文逗号分隔,每张图片最大4M
face_id_list 在萝卜头注册的人脸id,如果有多个id,用英文逗号分隔
go语言范例:
package main
import (
"bytes"
"fmt"
"io/ioutil"
"mime/multipart"
"net/http"
"time"
)
func main() {
var buff bytes.Buffer
writer := multipart.NewWriter(&buff)
pic_url_list := `http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/timg.jpg,http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/t2.jpg,http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/t3.jpg`
face_id_list := `9b4ykzssq8cyfnds46ksg9sv5tx6kevy,umq795jvu2y7iatgiim7zg5g9ns73fbw,ic6zq33ey7mjdp5ggm7rfb25eiseqpj3`
writer.WriteField("pic_url_list", pic_url_list)
writer.WriteField("face_id_list", face_id_list)
writer.WriteField("token", "jK893k5dGIiGGxx5ipopWOwCg0HPnSGN")
writer.Close()
var client http.Client
resp, err := client.Post("https://apiyf.robotscloud.com/hsr/v1/detect_compare_fast", writer.FormDataContentType(), &buff)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
data, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(data))
}
返回结果:
范例:
{
"ret": 0,
"msg": "ok",
"data": [
{
"pic_url": "http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/t3.jpg",
"hsr_list": [
{
"person": {
"coordinate": [
69,
108,
470,
300
],
"confidence": 0.4212017059326172
}
}
],
"face_list": [
{
"face": {
"coordinate": [
229,
77,
368,
256
],
"confidence": 0.9985519051551819
}
}
],
"similarity_list": [
{
"face_id": "9b4ykzssq8cyfnds46ksg9sv5tx6kevy",
"similarity": 1.0000000029210283
},
{
"face_id": "umq795jvu2y7iatgiim7zg5g9ns73fbw",
"similarity": 0.0031758294712535074
},
{
"face_id": "ic6zq33ey7mjdp5ggm7rfb25eiseqpj3",
"similarity": 0.6538354029810238
}
]
},
{
"pic_url": "http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/t2.jpg",
"hsr_list": [
{
"person": {
"coordinate": [
120,
0,
533,
300
],
"confidence": 0.6171044707298279
}
}
],
"face_list": [
{
"face": {
"coordinate": [
236,
19,
399,
220
],
"confidence": 0.9999334812164307
}
}
],
"similarity_list": [
{
"face_id": "9b4ykzssq8cyfnds46ksg9sv5tx6kevy",
"similarity": 0.003175870626410295
},
{
"face_id": "umq795jvu2y7iatgiim7zg5g9ns73fbw",
"similarity": 1.000000023084873
},
{
"face_id": "ic6zq33ey7mjdp5ggm7rfb25eiseqpj3",
"similarity": 0.01966740161338813
}
]
},
{
"pic_url": "http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/timg.jpg",
"hsr_list": [
{
"person": {
"coordinate": [
0,
11,
554,
645
],
"confidence": 1.0651928186416626
}
}
],
"face_list": [
{
"face": {
"coordinate": [
231,
87,
510,
440
],
"confidence": 0.9993162155151367
}
}
],
"similarity_list": [
{
"face_id": "9b4ykzssq8cyfnds46ksg9sv5tx6kevy",
"similarity": 0.6538353411772075
},
{
"face_id": "umq795jvu2y7iatgiim7zg5g9ns73fbw",
"similarity": 0.01966740666296612
},
{
"face_id": "ic6zq33ey7mjdp5ggm7rfb25eiseqpj3",
"similarity": 0.9999999824186342
}
]
}
]
}
ret 0正常返回,非0为错误值
msg 消息描述
data 检测结果,每张图片与注册的face_id下的图片对比结果
{
"pic_url": "http://app8hyf.oss-cn-hangzhou.aliyuncs.com/teststs/t2.jpg",
"hsr_list": [
{
"person": {
"coordinate": [
120,
0,
533,
300
],
"confidence": 0.6171044707298279
}
}
],
"face_list": [
{
"face": {
"coordinate": [
236,
19,
399,
220
],
"confidence": 0.9999334812164307
}
}
],
"similarity_list": [
{
"face_id": "9b4ykzssq8cyfnds46ksg9sv5tx6kevy",
"similarity": 0.003175870626410295
},
{
"face_id": "umq795jvu2y7iatgiim7zg5g9ns73fbw",
"similarity": 1.000000023084873
},
{
"face_id": "ic6zq33ey7mjdp5ggm7rfb25eiseqpj3",
"similarity": 0.01966740161338813
}
]
},
{
"pic_url": "被检测的图片rul",
"hsr_list": [
{
"person": {
"coordinate": [
人形坐标,依次为左上角X和Y坐标、右下角X和Y坐标
],
"confidence": 人形置信度
}
}
],
"face_list": [
{
"face": {
"coordinate": [
人脸坐标,依次为左上角X和Y坐标、右下角X和Y坐标
],
"confidence": 人脸置信度
}
}
],
"similarity_list": [
{
"face_id": 在萝卜头注册的人脸id,
"similarity": 上述pic_url指定待检测的公网图片与注册id下的图片相似度
},
{
"face_id": "umq795jvu2y7iatgiim7zg5g9ns73fbw",
"similarity": 0.01966740666296612
},
{
"face_id": "ic6zq33ey7mjdp5ggm7rfb25eiseqpj3",
"similarity": 0.9999999824186342
}
]
}
https://api.jfgou.com/osr/v1/osr_detection
Post方法(enctype=“multipart/form-data”):
act:
参数:
service_key 用户在萝卜头注册、开通人形检测服务的ServiceKey
device_sn 设备序列号
service_code 在萝卜头注册的服务码
file 背景或者目标图片文件,支持PNG、JPG格式,最大4M
go语言范例:
package main
import (
"bytes"
"fmt"
"io/ioutil"
"mime/multipart"
"net/http"
)
func main() {
var buff bytes.Buffer
writer := multipart.NewWriter(&buff)
writer.WriteField("service_key", "O86hXeNXTs7ZTSieX0jmA2JbhVNlGpaJ")
//yunying writer.WriteField("service_key", "qg9vRfvofK9b4xsWh1kHnEb998lQZYwA")
writer.WriteField("device_sn", "xxx")
writer.WriteField("service_code", "xxx")
w, _ := writer.CreateFormFile("file", "1r.jpg")
dat, err := ioutil.ReadFile("f:/aa1.jpg")
w.Write(dat)
writer.Close()
var client http.Client
resp, err := client.Post("https://apiyf.robotscloud.com/osr/v1/osr_detection", writer.FormDataContentType(), &buff)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
data, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(data))
}
返回结果:
{
"ret": 0,
"msg": "ok",
"features": [
{
"obj": {
"type": 类型,
"coordinate": [
人脸坐标,依次为左上角X和Y坐标、右下角X和Y坐标
],
"confidence": 置信度
}
},
{
"obj": {
"type": "person",
"coordinate": [
202,
61,
783,
482
],
"confidence": 0.6479036211967468
}
},
{
"obj": {
"type": "person",
"coordinate": [
0,
36,
432,
557
],
"confidence": 0.5093856453895569
}
},
{
"obj": {
"type": "dog",
"coordinate": [
417,
341,
755,
548
],
"confidence": 0.732670783996582
}
},
{
"obj": {
"type": "chair",
"coordinate": [
276,
123,
806,
460
],
"confidence": 0.20509184896945953
}
},
{
"obj": {
"type": "chair",
"coordinate": [
0,
151,
441,
562
],
"confidence": 0.2707360088825226
}
},
{
"obj": {
"type": "chair",
"coordinate": [
784,
280,
882,
458
],
"confidence": 0.3392084240913391
}
},
{
"obj": {
"type": "sofa",
"coordinate": [
212,
117,
777,
471
],
"confidence": 0.5255260467529297
}
},
{
"obj": {
"type": "chair",
"coordinate": [
0,
151,
441,
562
],
"confidence": 0.2707360088825226
}
}
]
}
总共支持的类型有80种:person,bicycle,car,motorbike,aeroplane,bus,train,truck,boat,traffic light,fire hydrant,stop sign,parking meter,bench,bird,cat,dog,horse,sheep,cow,elephant,bear,zebra,giraffe,backpack,umbrella,handbag,tie,suitcase,frisbee,skis,snowboard,sports ball,kite,baseball bat,baseball glove,skateboard,surfboard,tennis racket,bottle,wine glass,cup,fork,knife,spoon,bowl,banana,apple,sandwich,orange,broccoli,carrot,hot dog,pizza,donut,cake,chair,sofa,pottedplant,bed,diningtable,toilet,tvmonitor,laptop,mouse,remote,keyboard,cell phone,microwave,oven,toaster,sink,refrigerator,book,clock,vase,scissors,teddy bear,hair drier,toothbrush