本文档介绍人脸检测定位DetectFace的语法及示例。

功能描述

DetectFace可以检测图片中的人脸并给出每张人脸定位和关键点信息。输出人脸数量、人脸矩形坐标、人脸姿态、105点个关键点坐标、双瞳孔中心坐标等信息。可支持最多上千个人脸的同时检测,支持平面360度旋转人脸检测,支持左右最大90度侧面人脸检测。

前提条件

请确保您已开通人脸人体服务,详情请参见服务开通

输入限制

  • 图片格式:JPEG、JPG、PNG、BMP。
  • 图像大小:图像大小不超过3M。
  • 图像分辨率:图片大小要求5×5像素以上。
  • URL地址中不能包含中文字符。

调试

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

请求参数

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

要执行的操作。取值:DetectFace。

ImageURL String https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/tiankong/6%E4%BA%BA%E8%84%B8%E5%AE%9A%E4%BD%8D%E6%A3%80%E6%B5%8B.jpg

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

返回数据

名称 类型 示例值 描述
Data Struct

返回的结果数据内容。

FaceCount Integer 1

检测出来的人脸个数。

FaceProbabilityList List 1

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

FaceRectangles List [153,4,310,426]

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

LandmarkCount Integer 105

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

Landmarks List 179.71014404296875

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

PoseList List 0.86857914924621582

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

  • yaw为左右角度,取值范围-90~90。
  • pitch为上下角度,取值范围-90~90。
  • roll为平面旋转角度,取值范围-180~180。
Pupils List 232.2469482421875

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

RequestId String 765E5F87-0BAB-4553-AEF6-27CA7EC8DD14

请求ID。

示例

请求示例

http(s)://facebody.cn-shanghai.aliyuncs.com/?Action=DetectFace
&ImageURL=https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/tiankong/6%E4%BA%BA%E8%84%B8%E5%AE%9A%E4%BD%8D%E6%A3%80%E6%B5%8B.jpg
&<公共请求参数>

正常返回示例

XML 格式

<RequestId>765E5F87-0BAB-4553-AEF6-27CA7EC8DD14</RequestId>
<Data>
    <FaceProbabilityList>1</FaceProbabilityList>
    <LandmarkCount>105</LandmarkCount>
    <FaceRectangles>153</FaceRectangles>
    <FaceRectangles>4</FaceRectangles>
    <FaceRectangles>310</FaceRectangles>
    <FaceRectangles>426</FaceRectangles>
    <Landmarks>179.71014404296875</Landmarks>
    <Landmarks>170.73817443847656</Landmarks>
    <Landmarks>272.2652587890625</Landmarks>
    <Landmarks>157.37681579589844</Landmarks>
    <Landmarks>219.99136352539062</Landmarks>
    <Landmarks>138.14523315429688</Landmarks>
    <Landmarks>225.23085021972656</Landmarks>
    <Landmarks>158.95890808105469</Landmarks>
    <Landmarks>185.70263671875</Landmarks>
    <Landmarks>152.85685729980469</Landmarks>
    <Landmarks>201.68373107910156</Landmarks>
    <Landmarks>142.79023742675781</Landmarks>
    <Landmarks>238.904541015625</Landmarks>
    <Landmarks>139.97918701171875</Landmarks>
    <Landmarks>256.82455444335938</Landmarks>
    <Landmarks>146.32713317871094</Landmarks>
    <Landmarks>194.82615661621094</Landmarks>
    <Landmarks>166.47134399414062</Landmarks>
    <Landmarks>209.75827026367188</Landmarks>
    <Landmarks>161.65388488769531</Landmarks>
    <Landmarks>240.84988403320312</Landmarks>
    <Landmarks>157.32872009277344</Landmarks>
    <Landmarks>256.55743408203125</Landmarks>
    <Landmarks>157.42100524902344</Landmarks>
    <Landmarks>340.12371826171875</Landmarks>
    <Landmarks>153.27998352050781</Landmarks>
    <Landmarks>440.71875</Landmarks>
    <Landmarks>150.00384521484375</Landmarks>
    <Landmarks>391.6318359375</Landmarks>
    <Landmarks>118.40993499755859</Landmarks>
    <Landmarks>390.32373046875</Landmarks>
    <Landmarks>142.20878601074219</Landmarks>
    <Landmarks>353.94973754882812</Landmarks>
    <Landmarks>137.17253112792969</Landmarks>
    <Landmarks>371.682861328125</Landmarks>
    <Landmarks>125.5225830078125</Landmarks>
    <Landmarks>412.69549560546875</Landmarks>
    <Landmarks>119.94770050048828</Landmarks>
    <Landmarks>430.36920166015625</Landmarks>
    <Landmarks>131.47018432617188</Landmarks>
    <Landmarks>357.1640625</Landmarks>
    <Landmarks>151.02610778808594</Landmarks>
    <Landmarks>373.52310180664062</Landmarks>
    <Landmarks>145.79440307617188</Landmarks>
    <Landmarks>407.47354125976562</Landmarks>
    <Landmarks>141.4842529296875</Landmarks>
    <Landmarks>424.18548583984375</Landmarks>
    <Landmarks>145.30416870117188</Landmarks>
    <Landmarks>195.20571899414062</Landmarks>
    <Landmarks>172.99592590332031</Landmarks>
    <Landmarks>264.1842041015625</Landmarks>
    <Landmarks>175.64772033691406</Landmarks>
    <Landmarks>201.9620361328125</Landmarks>
    <Landmarks>165.44195556640625</Landmarks>
    <Landmarks>210.41879272460938</Landmarks>
    <Landmarks>159.87730407714844</Landmarks>
    <Landmarks>220.20231628417969</Landmarks>
    <Landmarks>157.31990051269531</Landmarks>
    <Landmarks>230.29527282714844</Landmarks>
    <Landmarks>156.50277709960938</Landmarks>
    <Landmarks>240.31072998046875</Landmarks>
    <Landmarks>157.93875122070312</Landmarks>
    <Landmarks>249.65402221679688</Landmarks>
    <Landmarks>161.80715942382812</Landmarks>
    <Landmarks>257.81134033203125</Landmarks>
    <Landmarks>167.78779602050781</Landmarks>
    <Landmarks>203.01669311523438</Landmarks>
    <Landmarks>177.63198852539062</Landmarks>
    <Landmarks>211.61502075195312</Landmarks>
    <Landmarks>180.55734252929688</Landmarks>
    <Landmarks>220.51123046875</Landmarks>
    <Landmarks>182.39085388183594</Landmarks>
    <Landmarks>229.51496887207031</Landmarks>
    <Landmarks>183.58349609375</Landmarks>
    <Landmarks>238.59555053710938</Landmarks>
    <Landmarks>183.47145080566406</Landmarks>
    <Landmarks>247.61610412597656</Landmarks>
    <Landmarks>182.42185974121094</Landmarks>
    <Landmarks>256.4852294921875</Landmarks>
    <Landmarks>180.46705627441406</Landmarks>
    <Landmarks>358.20834350585938</Landmarks>
    <Landmarks>178.58555603027344</Landmarks>
    <Landmarks>425.43515014648438</Landmarks>
    <Landmarks>178.329345703125</Landmarks>
    <Landmarks>365.3782958984375</Landmarks>
    <Landmarks>171.73324584960938</Landmarks>
    <Landmarks>373.48919677734375</Landmarks>
    <Landmarks>166.03616333007812</Landmarks>
    <Landmarks>382.61102294921875</Landmarks>
    <Landmarks>162.1949462890625</Landmarks>
    <Landmarks>392.28146362304688</Landmarks>
    <Landmarks>160.03532409667969</Landmarks>
    <Landmarks>402.13555908203125</Landmarks>
    <Landmarks>160.88055419921875</Landmarks>
    <Landmarks>411.23739624023438</Landmarks>
    <Landmarks>164.75863647460938</Landmarks>
    <Landmarks>419.2620849609375</Landmarks>
    <Landmarks>170.57069396972656</Landmarks>
    <Landmarks>366.05047607421875</Landmarks>
    <Landmarks>182.50018310546875</Landmarks>
    <Landmarks>374.58065795898438</Landmarks>
    <Landmarks>184.53480529785156</Landmarks>
    <Landmarks>383.2061767578125</Landmarks>
    <Landmarks>186.11038208007812</Landmarks>
    <Landmarks>391.9453125</Landmarks>
    <Landmarks>186.82763671875</Landmarks>
    <Landmarks>400.71224975585938</Landmarks>
    <Landmarks>186.64024353027344</Landmarks>
    <Landmarks>409.3509521484375</Landmarks>
    <Landmarks>185.12957763671875</Landmarks>
    <Landmarks>417.70175170898438</Landmarks>
    <Landmarks>182.45802307128906</Landmarks>
    <Landmarks>311.88607788085938</Landmarks>
    <Landmarks>182.10751342773438</Landmarks>
    <Landmarks>309.95230102539062</Landmarks>
    <Landmarks>254.42999267578125</Landmarks>
    <Landmarks>310.84780883789062</Landmarks>
    <Landmarks>218.10501098632812</Landmarks>
    <Landmarks>309.51522827148438</Landmarks>
    <Landmarks>274.32846069335938</Landmarks>
    <Landmarks>262.49688720703125</Landmarks>
    <Landmarks>268.82608032226562</Landmarks>
    <Landmarks>355.62954711914062</Landmarks>
    <Landmarks>269.93975830078125</Landmarks>
    <Landmarks>236.15850830078125</Landmarks>
    <Landmarks>324.57522583007812</Landmarks>
    <Landmarks>372.05328369140625</Landmarks>
    <Landmarks>326.76724243164062</Landmarks>
    <Landmarks>245.39669799804688</Landmarks>
    <Landmarks>323.29855346679688</Landmarks>
    <Landmarks>362.80520629882812</Landmarks>
    <Landmarks>324.61972045898438</Landmarks>
    <Landmarks>310.9381103515625</Landmarks>
    <Landmarks>316.81216430664062</Landmarks>
    <Landmarks>294.552978515625</Landmarks>
    <Landmarks>312.74566650390625</Landmarks>
    <Landmarks>325.814453125</Landmarks>
    <Landmarks>312.63739013671875</Landmarks>
    <Landmarks>265.41305541992188</Landmarks>
    <Landmarks>318.95077514648438</Landmarks>
    <Landmarks>349.33834838867188</Landmarks>
    <Landmarks>318.33029174804688</Landmarks>
    <Landmarks>250.85694885253906</Landmarks>
    <Landmarks>322.133056640625</Landmarks>
    <Landmarks>279.91876220703125</Landmarks>
    <Landmarks>315.54721069335938</Landmarks>
    <Landmarks>337.71380615234375</Landmarks>
    <Landmarks>314.92578125</Landmarks>
    <Landmarks>360.66098022460938</Landmarks>
    <Landmarks>322.63876342773438</Landmarks>
    <Landmarks>309.97821044921875</Landmarks>
    <Landmarks>356.20327758789062</Landmarks>
    <Landmarks>271.77685546875</Landmarks>
    <Landmarks>344.046875</Landmarks>
    <Landmarks>342.51605224609375</Landmarks>
    <Landmarks>345.31179809570312</Landmarks>
    <Landmarks>253.62734985351562</Landmarks>
    <Landmarks>334.93203735351562</Landmarks>
    <Landmarks>289.9044189453125</Landmarks>
    <Landmarks>353.11611938476562</Landmarks>
    <Landmarks>327.2451171875</Landmarks>
    <Landmarks>353.69442749023438</Landmarks>
    <Landmarks>357.5936279296875</Landmarks>
    <Landmarks>336.53240966796875</Landmarks>
    <Landmarks>309.15228271484375</Landmarks>
    <Landmarks>326.41497802734375</Landmarks>
    <Landmarks>308.88818359375</Landmarks>
    <Landmarks>333.93991088867188</Landmarks>
    <Landmarks>277.3455810546875</Landmarks>
    <Landmarks>323.43292236328125</Landmarks>
    <Landmarks>277.18072509765625</Landmarks>
    <Landmarks>328.50454711914062</Landmarks>
    <Landmarks>335.92013549804688</Landmarks>
    <Landmarks>323.72109985351562</Landmarks>
    <Landmarks>335.80661010742188</Landmarks>
    <Landmarks>329.20504760742188</Landmarks>
    <Landmarks>261.369873046875</Landmarks>
    <Landmarks>323.7965087890625</Landmarks>
    <Landmarks>261.2982177734375</Landmarks>
    <Landmarks>325.84347534179688</Landmarks>
    <Landmarks>293.2855224609375</Landmarks>
    <Landmarks>324.51315307617188</Landmarks>
    <Landmarks>292.90478515625</Landmarks>
    <Landmarks>331.98046875</Landmarks>
    <Landmarks>322.52703857421875</Landmarks>
    <Landmarks>324.97256469726562</Landmarks>
    <Landmarks>322.50399780273438</Landmarks>
    <Landmarks>332.465087890625</Landmarks>
    <Landmarks>349.37088012695312</Landmarks>
    <Landmarks>323.92410278320312</Landmarks>
    <Landmarks>349.35845947265625</Landmarks>
    <Landmarks>327.22216796875</Landmarks>
    <Landmarks>131.20266723632812</Landmarks>
    <Landmarks>171.72915649414062</Landmarks>
    <Landmarks>485.82687377929688</Landmarks>
    <Landmarks>181.40484619140625</Landmarks>
    <Landmarks>300.39315795898438</Landmarks>
    <Landmarks>435.84906005859375</Landmarks>
    <Landmarks>155.93305969238281</Landmarks>
    <Landmarks>334.67413330078125</Landmarks>
    <Landmarks>449.81655883789062</Landmarks>
    <Landmarks>340.6591796875</Landmarks>
    <Landmarks>137.3551025390625</Landmarks>
    <Landmarks>253.60928344726562</Landmarks>
    <Landmarks>473.96920776367188</Landmarks>
    <Landmarks>261.82354736328125</Landmarks>
    <Landmarks>218.69778442382812</Landmarks>
    <Landmarks>404.356689453125</Landmarks>
    <Landmarks>383.27932739257812</Landmarks>
    <Landmarks>406.52761840820312</Landmarks>
    <FaceCount>1</FaceCount>
    <PoseList>0.86857914924621582</PoseList>
    <PoseList>-1.3923481702804565</PoseList>
    <PoseList>1.8193349838256836</PoseList>
    <Pupils>232.2469482421875</Pupils>
    <Pupils>170.73431396484375</Pupils>
    <Pupils>17.970651626586914</Pupils>
    <Pupils>387.22463989257812</Pupils>
    <Pupils>173.99905395507812</Pupils>
    <Pupils>17.970651626586914</Pupils>
</Data>

JSON 格式

{
	"RequestId": "765E5F87-0BAB-4553-AEF6-27CA7EC8DD14",
	"Data": {
		"FaceProbabilityList": [
			1
		],
		"LandmarkCount": 105,
		"FaceRectangles": [
			153,
			4,
			310,
			426
		],
		"Landmarks": [
			"179.71014404296875",
			"170.73817443847656",
			"272.2652587890625",
			"157.37681579589844",
			"219.99136352539062",
			"138.14523315429688",
			"225.23085021972656",
			"158.95890808105469",
			185.70263671875,
			"152.85685729980469",
			"201.68373107910156",
			"142.79023742675781",
			"238.904541015625",
			"139.97918701171875",
			"256.82455444335938",
			"146.32713317871094",
			"194.82615661621094",
			"166.47134399414062",
			"209.75827026367188",
			"161.65388488769531",
			"240.84988403320312",
			"157.32872009277344",
			"256.55743408203125",
			"157.42100524902344",
			"340.12371826171875",
			"153.27998352050781",
			440.71875,
			"150.00384521484375",
			391.6318359375,
			"118.40993499755859",
			390.32373046875,
			"142.20878601074219",
			"353.94973754882812",
			"137.17253112792969",
			"371.682861328125",
			"125.5225830078125",
			"412.69549560546875",
			"119.94770050048828",
			"430.36920166015625",
			"131.47018432617188",
			357.1640625,
			"151.02610778808594",
			"373.52310180664062",
			"145.79440307617188",
			"407.47354125976562",
			"141.4842529296875",
			"424.18548583984375",
			"145.30416870117188",
			"195.20571899414062",
			"172.99592590332031",
			"264.1842041015625",
			"175.64772033691406",
			"201.9620361328125",
			"165.44195556640625",
			"210.41879272460938",
			"159.87730407714844",
			"220.20231628417969",
			"157.31990051269531",
			"230.29527282714844",
			"156.50277709960938",
			"240.31072998046875",
			"157.93875122070312",
			"249.65402221679688",
			"161.80715942382812",
			"257.81134033203125",
			"167.78779602050781",
			"203.01669311523438",
			"177.63198852539062",
			"211.61502075195312",
			"180.55734252929688",
			220.51123046875,
			"182.39085388183594",
			"229.51496887207031",
			183.58349609375,
			"238.59555053710938",
			"183.47145080566406",
			"247.61610412597656",
			"182.42185974121094",
			"256.4852294921875",
			"180.46705627441406",
			"358.20834350585938",
			"178.58555603027344",
			"425.43515014648438",
			"178.329345703125",
			"365.3782958984375",
			"171.73324584960938",
			"373.48919677734375",
			"166.03616333007812",
			"382.61102294921875",
			"162.1949462890625",
			"392.28146362304688",
			"160.03532409667969",
			"402.13555908203125",
			"160.88055419921875",
			"411.23739624023438",
			"164.75863647460938",
			"419.2620849609375",
			"170.57069396972656",
			"366.05047607421875",
			"182.50018310546875",
			"374.58065795898438",
			"184.53480529785156",
			"383.2061767578125",
			"186.11038208007812",
			391.9453125,
			186.82763671875,
			"400.71224975585938",
			"186.64024353027344",
			"409.3509521484375",
			"185.12957763671875",
			"417.70175170898438",
			"182.45802307128906",
			"311.88607788085938",
			"182.10751342773438",
			"309.95230102539062",
			"254.42999267578125",
			"310.84780883789062",
			"218.10501098632812",
			"309.51522827148438",
			"274.32846069335938",
			"262.49688720703125",
			"268.82608032226562",
			"355.62954711914062",
			"269.93975830078125",
			"236.15850830078125",
			"324.57522583007812",
			"372.05328369140625",
			"326.76724243164062",
			"245.39669799804688",
			"323.29855346679688",
			"362.80520629882812",
			"324.61972045898438",
			"310.9381103515625",
			"316.81216430664062",
			"294.552978515625",
			"312.74566650390625",
			325.814453125,
			"312.63739013671875",
			"265.41305541992188",
			"318.95077514648438",
			"349.33834838867188",
			"318.33029174804688",
			"250.85694885253906",
			"322.133056640625",
			"279.91876220703125",
			"315.54721069335938",
			"337.71380615234375",
			314.92578125,
			"360.66098022460938",
			"322.63876342773438",
			"309.97821044921875",
			"356.20327758789062",
			271.77685546875,
			344.046875,
			"342.51605224609375",
			"345.31179809570312",
			"253.62734985351562",
			"334.93203735351562",
			"289.9044189453125",
			"353.11611938476562",
			327.2451171875,
			"353.69442749023438",
			"357.5936279296875",
			"336.53240966796875",
			"309.15228271484375",
			"326.41497802734375",
			308.88818359375,
			"333.93991088867188",
			"277.3455810546875",
			"323.43292236328125",
			"277.18072509765625",
			"328.50454711914062",
			"335.92013549804688",
			"323.72109985351562",
			"335.80661010742188",
			"329.20504760742188",
			"261.369873046875",
			"323.7965087890625",
			"261.2982177734375",
			"325.84347534179688",
			"293.2855224609375",
			"324.51315307617188",
			292.90478515625,
			331.98046875,
			"322.52703857421875",
			"324.97256469726562",
			"322.50399780273438",
			"332.465087890625",
			"349.37088012695312",
			"323.92410278320312",
			"349.35845947265625",
			327.22216796875,
			"131.20266723632812",
			"171.72915649414062",
			"485.82687377929688",
			"181.40484619140625",
			"300.39315795898438",
			"435.84906005859375",
			"155.93305969238281",
			"334.67413330078125",
			"449.81655883789062",
			340.6591796875,
			"137.3551025390625",
			"253.60928344726562",
			"473.96920776367188",
			"261.82354736328125",
			"218.69778442382812",
			"404.356689453125",
			"383.27932739257812",
			"406.52761840820312"
		],
		"FaceCount": 1,
		"PoseList": [
			"0.86857914924621582",
			"-1.3923481702804565",
			"1.8193349838256836"
		],
		"Pupils": [
			"232.2469482421875",
			"170.73431396484375",
			"17.970651626586914",
			"387.22463989257812",
			"173.99905395507812",
			"17.970651626586914"
		]
	}
}

错误码

关于人脸检测定位的错误码,详情请参见常见错误码

SDK参考

单击SDK简介查看SDK信息。