本文介绍人脸属性识别RecognizeFace的语法及示例。

功能描述

人脸属性识别可以识别检测人脸的性别、年龄、表情、眼镜、帽子五种属性,返回人脸的1024维深度学习特征。基于这个特征并按照特征比较规则,可以实现高性能的人脸识别。

应用场景

客户群体分析:对商场内光顾的客户,识别其性别、年龄等信息,并刻画客户群体特征。

特色优势

覆盖多个年龄段。

前提条件

请确保您已开通人脸人体服务,若未开通服务请立即开通

输入限制

  • 图像格式:JPEG、JPG、PNG、BMP。
  • 图像大小:不超过3M。
  • 图像分辨率:大于32×32像素,小于2048×2048像素,人脸占比不低于64×64像素。
  • URL地址中不能包含中文字符。
说明 当图像分辨率超过最大限制时,请先将图片进行缩放,调整图片大小,具体请参见 图片缩放

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String RecognizeFace

系统规定参数。取值:RecognizeFace

ImageURL String http://viapi-test.oss-cn-shanghai.aliyuncs.com/sanjiye-meizi/%E4%BA%BA%E8%84%B8%E5%B1%9E%E6%80%A7%E8%AF%86%E5%88%AB.jpg

图像URL地址。当前仅支持上海地域的OSS链接,如何生成URL请参见生成URL

返回数据

名称 类型 示例值 描述
RequestId String 8251C88E-8273-4DBF-94FB-A6BCB268CEA2

请求ID。

Data Object

返回的结果数据内容。

Pupils Array of Float [243.02786254882812,149.0238037109375,7.3701672554016113,315.86138916015625,140.451416015625,7.3701672554016113]

左右两个瞳孔的中心点坐标和半径,每个人脸6个浮点数,顺序为[left_iris_cenpt.x, left_iris_cenpt.y, left_iris_radius, right_iris_cenpt.x, right_iris_cenpt.y, right_iris_radis]

GenderList Array of Integer 1

识别到的人脸性别。如有多个人脸,则依次返回。

  • 0:女性
  • 1:男性
Expressions Array of Integer 0

人脸识别的表情结果。包括:

  • 0:中性
  • 1:微笑
DenseFeatures Array of String 0.022202443331480026

人脸识别返回的特征。如有多个人脸,则依次返回。

FaceCount Integer 1

检测出来的人脸个数。

Landmarks Array of Float 213.98641967773438

人脸的特征点定位结果,每个人脸返回一组特征点位置,表示方式为(x0, y0, x1, y1, ……)。如有多个人脸,则依次返回,返回定位浮点数。

LandmarkCount Integer 105

人脸检测的特征点数目,目前固定为105点。依次为:眉毛24点,眼睛32点,鼻子6点,嘴巴34点,外轮廓9点。

Qualities Object

人脸质量情况,分数越高表示越有利于识别。

ScoreList Array of Float 79.0

质量综合分数,分数越高越有利于识别,取值范围(0,100]。如有多张人脸,则依次返回。

BlurList Array of Float 95.37

人脸模糊度对识别的影响分数,分数越高越有利于识别,取值范围(0,100]。如有多个人脸,则依次顺延。

FnfList Array of Float 100

人脸正确度对识别的影响分数,分数越高越有利于识别,取值范围(0,100]。如有多个人脸,则依次顺延。

GlassList Array of Float 99.75

眼镜等上半脸遮挡对识别的影响分数,分数越高越有利于识别,取值范围(0,100]。如有多个人脸,则依次顺延。

IlluList Array of Float 79.10

光照对识别的影响分数,分数越高越有利于识别,取值范围(0,100]。如有多个人脸,则依次顺延。

MaskList Array of Float 88.3

口罩等下半脸遮挡对识别的影响分数,分数越高越有利于识别,取值范围(0,100]。如有多个人脸,则依次顺延。

NoiseList Array of Float 77.39

图片噪声对识别的影响分数,分数越高越有利于识别,取值范围(0,100]。如有多个人脸,则依次顺延。

PoseList Array of Float 99.82

姿态对识别的影响分数,分数越高越有利于识别,取值范围(0,100]。如有多个人脸,则依次顺延。

BeautyList Array of Float 49

颜值分数,分值越高颜值越高,取值范围(0-100]。

HatList Array of Integer 0

人脸是否佩戴帽子。

  • 0:无帽子
  • 1:有帽子
FaceProbabilityList Array of Float 1

返回人脸检测的概率,取值范围0~1。如有多个人脸,则依次返回。例如有两个人脸则返回[face_prob1, face_prob2]

Glasses Array of Integer 1

人脸是否佩戴眼镜。

  • 0:不戴眼镜
  • 1:佩戴普通眼镜
  • 2:佩戴墨镜
FaceRectangles Array of Integer [215,57,172, 229]

返回人脸矩形框,格式为[left, top, width, height]。如有多个人脸,则依次顺延,返回矩形框。例如有两个人脸则返回[left1, top1, width1, height1, left2, top2, width2, height2]

PoseList Array of Float [-15.702389717102051, 8.4830875396728516,0.080579757690429688"]

返回人脸姿态,格式为[yaw, pitch, roll]。如有多个人脸,则依次返回。

  • yaw为左右角度,取值范围-90~90。
  • pitch为上下角度,取值范围-90~90。
  • roll为平面旋转角度,取值范围-180~180。
AgeList Array of Integer 55

图片中人脸年龄,取值范围0~100。如有多个人脸,依次返回多个人脸的年龄。

DenseFeatureLength Integer 1024

人脸识别返回的特征维度,目前固定为1024。

Masks Array of Long 0

人脸是否佩戴口罩。

  • 0:未佩戴口罩
  • 1:佩戴口罩
  • 2:未正确佩戴口罩

示例

请求示例

http(s)://[Endpoint]/?Action=RecognizeFace
&ImageURL=http://viapi-test.oss-cn-shanghai.aliyuncs.com/sanjiye-meizi/%E4%BA%BA%E8%84%B8%E5%B1%9E%E6%80%A7%E8%AF%86%E5%88%AB.jpg
&<公共请求参数>

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<RecognizeFaceResponse>
    <RequestId>8251C88E-8273-4DBF-94FB-A6BCB268CEA2</RequestId>
    <Data>
        <BeautyList>49</BeautyList>
        <FaceRectangles>215</FaceRectangles>
        <FaceRectangles>48</FaceRectangles>
        <FaceRectangles>165</FaceRectangles>
        <FaceRectangles>239</FaceRectangles>
        <Qualities>
            <NoiseList>98.41960906982422</NoiseList>
            <ScoreList>87.96944427490234</ScoreList>
            <BlurList>99.99459075927734</BlurList>
            <MaskList>84.82530212402344</MaskList>
            <GlassList>99.34257507324219</GlassList>
            <FnfList>100</FnfList>
            <PoseList>17.248966217041016</PoseList>
            <IlluList>99.9954833984375</IlluList>
        </Qualities>
        <DenseFeatureLength>1024</DenseFeatureLength>
        <Masks>0</Masks>
        <PoseList>-13.350616455078125</PoseList>
        <PoseList>7.137346267700195</PoseList>
        <PoseList>0.6639551520347595</PoseList>
        <GenderList>1</GenderList>
        <Pupils>243.33584594726562</Pupils>
        <Pupils>149.0119171142578</Pupils>
        <Pupils>7.572455406188965</Pupils>
        <Pupils>316.94989013671875</Pupils>
        <Pupils>142.6491241455078</Pupils>
        <Pupils>7.572455406188965</Pupils>
        <DenseFeatures>-0.04283177852630615</DenseFeatures>
        <DenseFeatures>0.01496131718158722</DenseFeatures>
        <DenseFeatures>0.08304227143526077</DenseFeatures>
        <DenseFeatures>-0.006072732154279947</DenseFeatures>
        <DenseFeatures>-0.012721054255962372</DenseFeatures>
        <DenseFeatures>-0.024241730570793152</DenseFeatures>
        <DenseFeatures>-0.03138406202197075</DenseFeatures>
        <DenseFeatures>0.006191537249833345</DenseFeatures>
        <DenseFeatures>0.017898650839924812</DenseFeatures>
        <DenseFeatures>-0.03185232728719711</DenseFeatures>
        <DenseFeatures>-0.02717948891222477</DenseFeatures>
        <DenseFeatures>0.028409384191036224</DenseFeatures>
        <DenseFeatures>-0.03557640686631203</DenseFeatures>
        <DenseFeatures>-0.02255111373960972</DenseFeatures>
        <DenseFeatures>-0.030578967183828354</DenseFeatures>
        <DenseFeatures>0.011586467735469341</DenseFeatures>
        <DenseFeatures>-0.005520580802112818</DenseFeatures>
        <DenseFeatures>-0.0061850580386817455</DenseFeatures>
        <DenseFeatures>-0.023915085941553116</DenseFeatures>
        <DenseFeatures>0.014204374514520168</DenseFeatures>
        <FaceProbabilityList>0.9448931217193604</FaceProbabilityList>
        <HatList>0</HatList>
        <LandmarkCount>105</LandmarkCount>
        <AgeList>57</AgeList>
        <Glasses>1</Glasses>
        <Landmarks>222.13568115234375</Landmarks>
        <Landmarks>138.52761840820312</Landmarks>
        <Landmarks>260.9165344238281</Landmarks>
        <Landmarks>226.39784240722656</Landmarks>
        <Landmarks>306.2375183105469</Landmarks>
        <Landmarks>226.98062133789062</Landmarks>
        <Landmarks>305.8338928222656</Landmarks>
        <Landmarks>227.38076782226562</Landmarks>
        <Landmarks>218.0395965576172</Landmarks>
        <Landmarks>154.48680114746094</Landmarks>
        <Landmarks>383.88299560546875</Landmarks>
        <Landmarks>152.27308654785156</Landmarks>
        <Landmarks>276.18603515625</Landmarks>
        <Landmarks>286.6674499511719</Landmarks>
        <Landmarks>223.247314453125</Landmarks>
        <Landmarks>234.28871154785156</Landmarks>
        <Landmarks>366.3158264160156</Landmarks>
        <Landmarks>248.72088623046875</Landmarks>
        <Landmarks>217.36123657226562</Landmarks>
        <Landmarks>194.63626098632812</Landmarks>
        <Landmarks>379.5048828125</Landmarks>
        <Landmarks>201.19459533691406</Landmarks>
        <Landmarks>241.69862365722656</Landmarks>
        <Landmarks>269.61834716796875</Landmarks>
        <Landmarks>327.7804870605469</Landmarks>
        <Landmarks>279.5162353515625</Landmarks>
        <Expressions>0</Expressions>
        <FaceCount>1</FaceCount>
    </Data>
</RecognizeFaceResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "8251C88E-8273-4DBF-94FB-A6BCB268CEA2",
  "Data" : {
    "BeautyList" : [ 49 ],
    "FaceRectangles" : [ 215, 48, 165, 239 ],
    "Qualities" : {
      "NoiseList" : [ 98.41960906982422 ],
      "ScoreList" : [ 87.96944427490234 ],
      "BlurList" : [ 99.99459075927734 ],
      "MaskList" : [ 84.82530212402344 ],
      "GlassList" : [ 99.34257507324219 ],
      "FnfList" : [ 100 ],
      "PoseList" : [ 17.248966217041016 ],
      "IlluList" : [ 99.9954833984375 ]
    },
    "DenseFeatureLength" : 1024,
    "Masks" : [ 0 ],
    "PoseList" : [ -13.350616455078125, 7.137346267700195, 0.6639551520347595 ],
    "GenderList" : [ 1 ],
    "Pupils" : [ 243.33584594726562, 149.0119171142578, 7.572455406188965, 316.94989013671875, 142.6491241455078, 7.572455406188965 ],
    "DenseFeatures" : [ -0.04283177852630615, 0.01496131718158722, 0.08304227143526077, -0.006072732154279947, -0.012721054255962372, -0.024241730570793152, -0.03138406202197075, 0.006191537249833345, 0.017898650839924812, -0.03185232728719711, -0.02717948891222477, 0.028409384191036224, -0.03557640686631203, -0.02255111373960972, -0.030578967183828354, 0.011586467735469341, -0.005520580802112818, -0.0061850580386817455, -0.023915085941553116, 0.014204374514520168 ],
    "FaceProbabilityList" : [ 0.9448931217193604 ],
    "HatList" : [ 0 ],
    "LandmarkCount" : 105,
    "AgeList" : [ 57 ],
    "Glasses" : [ 1 ],
    "Landmarks" : [ 222.13568115234375, 138.52761840820312, 260.9165344238281, 226.39784240722656, 306.2375183105469, 226.98062133789062, 305.8338928222656, 227.38076782226562, 218.0395965576172, 154.48680114746094, 383.88299560546875, 152.27308654785156, 276.18603515625, 286.6674499511719, 223.247314453125, 234.28871154785156, 366.3158264160156, 248.72088623046875, 217.36123657226562, 194.63626098632812, 379.5048828125, 201.19459533691406, 241.69862365722656, 269.61834716796875, 327.7804870605469, 279.5162353515625 ],
    "Expressions" : [ 0 ],
    "FaceCount" : 1
  }
}

错误码

关于人脸属性识别的错误码,详情请参见常见错误码

SDK参考

阿里云视觉AI能力支持使用SDK调用,具体可参见SDK总览下载安装。

安全声明

  • 请确保上传的图片或文件来源符合相应的法律法规。
  • 通过体验调试上传的临时文件有效期为1小时,在24小时后会被系统自动清理删除。