五官定位

最近更新时间:2019-01-24 16:45:05

注意:

  • 人脸识别全面升级接口,算法更强、性能更优,欢迎立即体验 人脸识别
  • 新老版本的接口不兼容,控制台的数据统计不互通,但计费模式相同,且共享计费阶梯。
  • 老版本接口我们仍继续维护,但建议您使用 新版人脸识别,体验更优服务。

接口描述

接口请求域名:https://recognition.image.myqcloud.com/face/shape
本接口(shape)用于对请求图片进行五官定位,计算构成人脸轮廓的 88 个点,包括眉毛(左右各 8 点)、眼睛(左右各 8 点)、鼻子( 13 点)、嘴巴( 22 点)、脸型轮廓( 21 点)。各部分的点的顺序如下图所示:
img

注意:

  • 本接口支持 HTTPS 协议,如果您现在使用的是 HTTP 协议,为了保障您的数据安全,请切换至 HTTPS。

输入参数

参数名 必选 类型 参数说明
appid String 接入项目的唯一标识,可在 账号信息云 API 密钥 中查看。
mode Int 检测模式,0:所有人脸,1:最大的人脸。
image Binary 图片内容。
url String 图片的 url,image 和 url 只需提供一个;如果都提供,只使用 url。

输出参数

字段 类型 说明
data.session_id String 相应请求的 session 标识符,可用于结果查询
data.image_width Int 请求图片的宽度
data.image_height Int 请求图片的高度
data.face_shape.face_profile Array(Point) 描述脸型轮廓的 21 点
data.face_shape.left_eye Array(Point) 描述左测眼睛轮廓的 8 点
data.face_shape.right_eye Array(Point) 描述右测眼睛轮廓的 8 点
data.face_shape.left_eyebrow Array(Point) 描述左测眉毛轮廓的 8 点
data.face_shape.right_eyebrow Array(Point) 描述右测眉毛轮廓的 8 点
data.face_shape.mouth Array(Point) 描述嘴巴轮廓的 22 点
data.face_shape.nose Array(Point) 描述鼻子轮廓的 13 点
code Int 返回状态码
message String 返回错误消息

Point 说明:

字段 类型 说明
x Int 坐标 x ,图片左上角为0。
y Int 坐标 y ,图片左上角为0。

示例

输入示例

使用 url

POST /face/shape HTTP/1.1
Authorization: FCHXdPTEwMDAwMzc5Jms9QUtJRGVRZDBrRU1yM2J4ZjhRckJi==
Host: recognition.image.myqcloud.com 
Content-Length: 123
Content-Type: application/json

{
  "appid":"123456",
  "mode":1,
  "url":"http://test-123456.image.myqcloud.com/test.jpg"
}

使用 image

POST /face/shape HTTP/1.1
Authorization: FCHXdPTEwMDAwMzc5Jms9QUtJRGVRZDBrRU1yM2J4ZjhRckJi==
Host: recognition.image.myqcloud.com 
Content-Length: 460
Content-Type: multipart/form-data;boundary=--------------acebdf13572468

----------------acebdf13572468
Content-Disposition: form-data; name="appid";

123456
----------------acebdf13572468
Content-Disposition: form-data; name="mode";
1
----------------acebdf13572468
Content-Disposition: form-data; name="image"; filename="test.jpg"
Content-Type: image/jpeg

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
----------------acebdf13572468--

输出示例

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 313
Content-Type: application/json

{
  "data":{
    "session_id": "",
    "image_height": 200,
    "image_width": 200,
    "face_shape": [{
      "face_profile": [{"x":48,"y":55},{"x":49,"y":61},{"x":49,"y":66},{"x":50,"y":71},{"x":51,"y":76},{"x":54,"y":81},{"x":56,"y":86},{"x":60,"y":90},{"x":65,"y":93},{"x":71,"y":95},{"x":77,"y":96},{"x":82,"y":95},{"x":87,"y":93},{"x":92,"y":90},{"x":94,"y":85},{"x":97,"y":81},{"x":99,"y":76},{"x":100,"y":71},{"x":101,"y":65},{"x":101,"y":60},{"x":101,"y":55}], 
      "left_eye":[{"x":62,"y":55},{"x":64,"y":56},{"x":66,"y":57},{"x":68,"y":57},{"x":70,"y":56},{"x":69,"y":54},{"x":66,"y":54},{"x":64,"y":54}], 
      "right_eye":[{"x":92,"y":55},{"x":90,"y":56},{"x":88,"y":56},{"x":86,"y":56},{"x":84,"y":56},{"x":85,"y":54},{"x":88,"y":53},{"x":90,"y":54}],
      "left_eyebrow":[{"x":56,"y":50},{"x":61,"y":50},{"x":65,"y":50},{"x":68,"y":50},{"x":73,"y":50},{"x":69,"y":47},{"x":64,"y":46},{"x":60,"y":47}],  
      "right_eyebrow":[{"x":97,"y":50},{"x":93,"y":50},{"x":89,"y":50},{"x":86,"y":50},{"x":82,"y":50},{"x":85,"y":47},{"x":90,"y":46},{"x":95,"y":46}],
      "mouth":[{"x":67,"y":80},{"x":70,"y":83},{"x":74,"y":85},{"x":78,"y":85},{"x":81,"y":84},{"x":83,"y":82},{"x":86,"y":80},{"x":84,"y":78},{"x":81,"y":77},{"x":78,"y":78},{"x":74,"y":78},{"x":71,"y":79},{"x":71,"y":81},{"x":74,"y":81},{"x":78,"y":81},{"x":80,"y":80},{"x":83,"y":80},{"x":83,"y":79},{"x":80,"y":79},{"x":78,"y":80},{"x":74,"y":80},{"x":71,"y":80}],
      "nose":[{"x":79,"y":68},{"x":77,"y":56},{"x":75,"y":60},{"x":74,"y":64},{"x":72,"y":67},{"x":70,"y":70},{"x":74,"y":72},{"x":78,"y":72},{"x":81,"y":72},{"x":85,"y":70},{"x":83,"y":66},{"x":81,"y":63},{"x":81,"y":59}]
}]
  },
  "code":0,
  "message":"OK"
}

错误码

API 错误码请查看 错误码说明