虎牙开放平台文档

hyExt.reg.onFacialLandmarkDetection

  • 监听当前直播间人脸特征点检测消息
  • 双面镜、两屏、三屏的时候提示接口不支持
  • 开启左右翻转后点的下标和识别部位的对应关系会发生变化
  • 引入版本 1.8.0
  • 适用终端
    • 虎牙直播助手-iOS:4.8.0
    • 虎牙直播助手-安卓:4.8.0
    • 虎牙直播PC客户端-主播侧:4.16.1.0

接口签名

declare namespace hyExt { module reg { /** * 监听当前直播间人脸特征点检测消息 * @param param 输入参数 */ function onFacialLandmarkDetection( param: FacialLandmarkDetectionReq ): Promise<void> } /** * 监听直播间人脸特征点参数 */ type FacialLandmarkDetectionReq = { /** * 人脸识别回调 */ callback: FacialCallback } /** * 人脸识别回调 * @param recognition 人脸识别消息 */ type FacialCallback = (recognition: FacialInfo) => void /** * 人脸识别消息 */ type FacialInfo = { /** * 画布信息 */ canvas: CanvasInfo /** * 人脸信息 */ faces: FaceInfo[] } /** * 画布信息 */ type CanvasInfo = { /** * 画布宽度 */ width: number /** * 画布高度 */ height: number } /** * 人脸信息 */ type FaceInfo = { /** * 人脸框 */ faceRect: FaceRect /** * 俯仰角(x轴)值域 [-90, 90] */ pitch: number /** * 偏航角(y轴)值域 [-90, 90] */ yaw: number /** * 翻滚角(z轴)值域 [-180, 180] */ roll: number /** * 人脸特征点 */ landmarks106: Landmark[] } /** * 人脸框信息 */ type FaceRect = { /** * 人脸框左上角横坐标(相对与视频区域左上角,单位是像素) */ x: number /** * 人脸框左上角纵坐标(相对与视频区域左上角,单位是像素) */ y: number /** * 人脸框宽度(相对与视频区域左上角,单位是像素) */ width: number /** * 人脸框高度(相对与视频区域左上角,单位是像素) */ height: number } /** * 人脸特征点信息 */ type Landmark = { /** * 横坐标(值域 [0, 画布宽],单位是像素) */ x: number /** * 纵坐标(值域 [0, 画布高],单位是像素) */ y: number } }

示例代码

hyExt.reg .onFacialLandmarkDetection({ callback: (recognition) => { const { canvas, faces } = recognition console.log("回调触发", recognition) }, }) .then(() => { console.log("调用hyExt.reg.onFacialLandmarkDetection成功") }) .catch((err) => { console.log("调用hyExt.reg.onFacialLandmarkDetection失败", err) })

角度示意:

2022 05 05 14 35 16

人脸点下标示意:

2022 05 05 14 36 26