人脸识别

原文链接
https://help.aliyun.com/document_detail/118976.html?source=5176.11533457&userCode=9foyedeh&type=copy

人脸查找1:N SDK调用说明
更新时间:2019-05-20 09:51:59

SDK下载
Java SDK
https://github.com/aliyun/aliyun-openapi-java-sdk/tree/master/aliyun-java-sdk-core

Maven
https://maven.aliyun.com/repository/central

com.aliyun aliyun-java-sdk-core 4.1.1 AddFace AddFace接口用于向人脸库中添加人脸

调用说明
//DefaultProfile.getProfile的参数分别是地域,access_key_id, access_key_secret
DefaultProfile profile = DefaultProfile.getProfile(“cn-shanghai”, “LTA****”, “******”);
DefaultAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.setMethod(MethodType.POST);
request.setDomain(“face.cn-shanghai.aliyuncs.com”);
request.setVersion(“2018-12-03”);
request.setAction(“AddFace”);
request.putBodyParameter(“Group”, “default”); //添加人脸的分组
request.putBodyParameter(“Person”, “ZhangSan”); //添加人脸的姓名
request.putBodyParameter(“Image”, “photo”); //添加人脸的编号
request.putBodyParameter(“ImageUrl”, “http://xxx.xx.com/xx.jpg”); //检测图片的URL
request.putBodyParameter(“Content”, “/9j/4AAQSkZJRgABA…”); //检测图片的内容,Base64编码
CommonResponse response = client.getCommonResponse(request);
System.out.println(response.getData());
当您使用远程图片地址时,请使用参数ImageUrl

当您使用本地图片时,请使用参数Content

返回参数
参数 类型 说明 举例
RequestId string 请求识别码 D7234082-6AA0-4405-B01D-966028A89BDF
Success string 成功标识 true
Code string 错误码 MissingParamGroup
Message string 错误信息 Group is mandatory for this action.
Data string 人脸添加返回值 ok
返回示例
{
“Data”:“ok”,
“RequestId”:“F6414398-4258-440C-B8C1-98B60142A2BE”,
“Success”:true
}
DeleteFace
DeleteFace接口用于从人脸库中删除人脸

调用说明
//DefaultProfile.getProfile的参数分别是地域,access_key_id, access_key_secret
DefaultProfile profile = DefaultProfile.getProfile(“cn-shanghai”, “LTA****”, “******”);
DefaultAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.setMethod(MethodType.POST);
request.setDomain(“face.cn-shanghai.aliyuncs.com”);
request.setVersion(“2018-12-03”);
request.setAction(“DeleteFace”);
request.putBodyParameter(“Group”, “default”); //添加人脸的分组
request.putBodyParameter(“Person”, “ZhangSan”); //添加人脸的姓名
request.putBodyParameter(“Image”, “photo”); //添加人脸的编号
CommonResponse response = client.getCommonResponse(request);
System.out.println(response.getData());
返回参数
参数 类型 说明 举例
RequestId string 请求识别码
Success string 成功标识 true
Code string 错误码 MissingParamGroup
Message string 错误信息 Group is mandatory for this action.
Data string 人脸添加返回值 ok
返回示例
{
“Data”:“ok”,
“RequestId”:“F6414398-4258-440C-B8C1-98B60142A2BE”,
“Success”:true
}
ListFace
ListFace接口用于列举注册库中的人脸。

调用说明
//DefaultProfile.getProfile的参数分别是地域,access_key_id, access_key_secret
DefaultProfile profile = DefaultProfile.getProfile(“cn-shanghai”, “LTA****”, “******”);
DefaultAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.setMethod(MethodType.POST);
request.setDomain(“face.cn-shanghai.aliyuncs.com”);
request.setVersion(“2018-12-03”);
request.setAction(“ListFace”);
request.putBodyParameter(“Group”, “default”); //列举的人脸组
CommonResponse response = client.getCommonResponse(request);
System.out.println(response.getData());
返回参数
参数 类型 说明 举例
RequestId string 请求识别码 D7234082-6AA0-4405-B01D-966028A89BDF
Success string 成功标识 true
Code string 错误码 MissingParamGroup
Message string 错误信息 Group is mandatory for this action.
Data string 人脸列举结果 {“list”:[{“person”:”ZhangSan”,”image”:”photo”}]}
返回示例
{
“Data”:{
“list”:[{
“image”:“default”,
“person”:“Ishikawa-Kasumi”
}],
“mark”:0
},
“RequestId”:“87AD40B5-C66D-4A50-9133-62BB3A092942”,
“Success”:true
}
ListGroup
ListGroup接口用于列举人脸组。

调用说明
//DefaultProfile.getProfile的参数分别是地域,access_key_id, access_key_secret
DefaultProfile profile = DefaultProfile.getProfile(“cn-shanghai”, “LTA****”, “******”);
DefaultAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.setMethod(MethodType.POST);
request.setDomain(“face.cn-shanghai.aliyuncs.com”);
request.setVersion(“2018-12-03”);
request.setAction(“ListGroup”);
CommonResponse response = client.getCommonResponse(request);
System.out.println(response.getData());
返回参数
参数 类型 说明 举例
RequestId string 请求识别码 D7234082-6AA0-4405-B01D-966028A89BDF
Success string 成功标识 true
Code string 错误码 MissingParamGroup
Message string 错误信息 Group is mandatory for this action.
Data string数组 人脸组列举结果 [“department1”,”department2”]
返回示例
{
“Data”:[“default”],
“RequestId”:“AA8E1203-9036-46AB-8D00-150492284DB5”,
“Success”:true
}
RecognizeFace
RecognizeFace接口用于查找注册库中的人脸。

调用说明
//DefaultProfile.getProfile的参数分别是地域,access_key_id, access_key_secret
DefaultProfile profile = DefaultProfile.getProfile(“cn-shanghai”, “LTA****”, “******”);
DefaultAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.setMethod(MethodType.POST);
request.setDomain(“face.cn-shanghai.aliyuncs.com”);
request.setVersion(“2018-12-03”);
request.setAction(“RecognizeFace”);
request.putBodyParameter(“Group”, “default”); //待识别的人脸分组
request.putBodyParameter(“ImageUrl”, “http://xxx.xx.com/xx.jpg”); //检测图片的URL
request.putBodyParameter(“Content”, “/9j/4AAQSkZJRgABA…”); //检测图片的内容,Base64编码
CommonResponse response = client.getCommonResponse(request);
System.out.println(response.getData());
返回参数
参数 类型 说明 举例
RequestId string 请求识别码 D7234082-6AA0-4405-B01D-966028A89BDF
Success string 成功标识 true
Code string 错误码 MissingParamGroup
Message string 错误信息 Group is mandatory for this action.
Data string 人脸查找结果 见Data说明
返回示例
{
“Data”:[{
“image”:“anyway”,
“person”:“anyway”,
“rect”:[
487,
142,
345,
447
],
“score”:1.0000005
}],
“RequestId”:“A759AD98-F400-490E-930F-959B78351987”,
“Success”:true
}
Data说明
参数 类型 说明 举例
person string 人脸组中匹配度最高的人脸姓名 ZhangSan
image image 人脸组中匹配度最高的人脸编号 photo
score float 匹配分值,取值范围为[-1, 1],分值越大,说明匹配度越高。根据我们的测试结果和使用体验,建议用户取判决阈值的最佳值为0.65, 用户也可以根据自己的需求和测试情况调整这个参数。 0.71
rect int数组 返回人脸矩形框,分别是[left, top, width, height] [145,98,138,176]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值