微软认知服务 人脸识别 API 之 确认
来源:互联网 发布:蒙泰软件使用教程 编辑:程序博客网 时间:2024/06/09 20:58
原文地址:https://dev.projectoxford.ai/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523a
确认是否两张脸属于同一个人或者是否一张脸属于一个人。
备注:
- 该 API 对于正脸或者接近正脸的图片正常工作
- 对于对准确性要求高的情况,请自行判断
Http Method
POST
Request URL
https://api.projectoxford.ai/face/v1.0/verify
Request headers
Content-Type(可选)string发送给 API 的 body 的媒体类型(Media type)Ocp-Apim-Subscription-Keystring提供访问该 API 的订阅 key。查找你的订阅
Request body
对于脸对脸的确认 request body 中的 JSON 字段:
字段类型描述faceId1String来自 Face - Detect 的 faceId faceId2String来自 另外一个 Face - Detect 的 faceId
对于脸对人的确认 request body 中的 JSON 字段:
字段类型描述faceIdString来自 Face - Detect 的 faceId personGroupIdString通过使用已经存在的 personGroupId 和 personId 来快速地加载一个指定的人。personGroupId 由 Person Group - Create a Person Group 创建personIdString在一个 person group 中指定某一个人。personId 由 Person - Create a Person 创建。
application/json
{ "faceId":"c5c24a82-6845-4031-9d5d-978df9175426", "peronId":"815df99c-598f-4926-930a-a734b3fd651c", "personGroupId":"sample_group"}
返回值 200
一个成功的调用会返回确认的结果。
Response body 中的 JSON 字段:
字段类型描述isIdenticalBoolean当两张脸属于同一个人或者一张脸属于某一个人,返回 true,否则 falseconfidenceNumber一个数字,表示一个表示是否两张脸属于同一个人或者一张脸属于某一个人的相似度的信息指数。默认的,如果信息指数大于 0.5,那么 isIdentical 会被设置为 true。这个对于想要重写 “isIdentical” 并且在他们自己的数据上进一步优化的高级人员来讲更有用
application/json
{ "isIdentical":true, "confidence":0.9}
返回值 400
JSON 中返回的错误代码和信息:
错误代码错误信息描述BadArgumentBad and unrecognizable JSON body.错误的和未被解析出来的 JSON bodyBadArgumentFace ID is invalid. faceId1, faceId2 or faceId is invalid and valid faceId comes from Face - Detect.
Face ID 不正确。 faceId1,faceId2 或者 faceId 不正确。正确的 faceId 从 Face - Detect 来。BadArgumentPerson ID is invalid. Valid personId is generated from Person - Create a Person for existing person.
Person ID 不正确。对于已经存在的人,正确的 personId 由 Person - Create a Person 创建BadArgumentRequest body is invalid.
Request body 不正确BadArgumentPerson group ID is invalid. Valid format should be a string composed by numbers, English letters in lower case, '-', '_', and no longer than 64 characters.
Person group ID 不正确。正确的格式应该是由数字,小写英文字母,“-”,“_” 组成的字符串,并且不应该多于64个字符。
application/json
{ "error":{ "code":"BadArgument", "message":"Request body is invalid." }}
返回值 401
JSON 中返回的错误代码和信息:
错误代码错误信息描述Unspecified错误的订阅 Key 或者用户/计划被封
application/json
{ "error":{ "code": "Unspecified", "message": "Access denied due to invalid subscription key. Make sure you are subscribed to an API you are trying to call and provide the right key." }}
返回值 403
application/json
{ "error":{ "statusCode": 403, "message": "Out of call volume quota. Quota will be replenished in 2.12 days." }}
返回值 404
在返回的 JSON 中的错误代码和信息:
错误代码错误信息描述FaceNotFoundFace is not found. The faceId is expired or not exist.
Face 没有被找到。FaceId 过期了或者不存在PersonNotFoundPerson is not found.
Person 没有找到PersonGroupNotFoundPerson Group is not found.
Person Group 没有找到
Face 没有被找到。FaceId 过期了或者不存在PersonNotFoundPerson is not found.
Person 没有找到PersonGroupNotFoundPerson Group is not found.
Person Group 没有找到
application/json
{ "error":{ "code":"PersonGroupNotFound", "message":"Person group 'sample_group' is not found." }}
返回值 415
不支持的媒体类型错误。该 API 只支持“application/json”。
application/json
{ "error":{ "code":"BadArgument", "message":"Invalid Media Type" }}
返回值 429
application/json
{ "error":{ "statusCode": 429, "message": "Rate limit is exceeded. Try again in 26 seconds." }}
示例代码
C#
using System;using System.Net.Http.Headers;using System.Text;using System.Net.Http;using System.Web;namespace CSHttpClientSample{ static class Program { static void Main() { MakeRequest(); Console.WriteLine("Hit ENTER to exit..."); Console.ReadLine(); } static async void MakeRequest() { var client = new HttpClient(); var queryString = HttpUtility.ParseQueryString(string.Empty); // Request headers client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}"); var uri = "https://api.projectoxford.ai/face/v1.0/verify?" + queryString; HttpResponseMessage response; // Request body byte[] byteData = Encoding.UTF8.GetBytes("{body}"); using (var content = new ByteArrayContent(byteData)) { content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >"); response = await client.PostAsync(uri, content); } } }}
Javascript
<!DOCTYPE html><html><head> <title>JSSample</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script></head><body><script type="text/javascript"> $(function() { var params = { // Request parameters }; $.ajax({ url: "https://api.projectoxford.ai/face/v1.0/verify?" + $.param(params), beforeSend: function(xhrObj){ // Request headers xhrObj.setRequestHeader("Content-Type","application/json"); xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}"); }, type: "POST", // Request body data: "{body}", }) .done(function(data) { alert("success"); }) .fail(function() { alert("error"); }); });</script></body></html>
0 0
- 微软认知服务 人脸识别 API 之 确认
- 微软认知服务 人脸识别 API 之 识别
- 微软认知服务 人脸识别 API 之 概述
- 微软认知服务 人脸识别 API 之 发现
- 微软认知服务 人脸识别 API 之 查找相似
- 微软认知服务开发实践(3) - 人脸识别
- 微软认知服务,人脸识别技术的初级实现
- Qt 调用微软认知 语音识别服务
- 微软认知服务开发实践(4) - 情绪识别
- 微软认知服务-Computer Vision API调用合集
- 图片识别之人脸识别API
- IBM近期扩充Watson认知API服务
- 使用微软人脸API实现人脸识别(java的URL方式)
- 微软认知服务开发实践(1) - 牛津计划简介
- 微软认知服务开发实践(2) - 计算机视觉
- 微软认知服务开发实践(5) - 视频检测
- 微软开源认知服务CNTK的测试(语音训练)
- 微信公众平台消息接口开发(24)图片识别之人脸识别API
- NetAdvantage控件使用:UltraGrid
- NXP LPC1769开发小结
- 25 JS基础之--5个数组元素遍历的方法
- 关于爬虫和反爬虫
- Linux下的cd命令
- 微软认知服务 人脸识别 API 之 确认
- 保序回归算法原理及Spark MLlib调用实例(Scala/Java/python)
- 26 JS基础之--数组API-案例
- Android Studio is on board
- js数组比较相等
- Redis和Memcache的区别
- Android Design Support Library(一)用TabLayout实现类似网易选项卡动态滑动效果
- 增强现实APP开启1元钞票到参观白宫
- NetAdvantage控件使用:UltraCombo