取得人脸侦测结果
目标 SDK
JavaScript
React
Vue
Flutter
ReactNative
Android
iOS
TIP 提示
您可以参考 示例程式码 和 API 参考 以了解更多详情。最相关的 API 包括:VideoFrameProcessedEvent 和 NormalizedFacebox。
若要取得每个相机画面侦测到的人脸,请透过 onVideoFrameProcessed 回呼函数存取 event.facebox 变数。此回调函数以每秒30Hz的频率(此频率取决于相机的帧率)传回处理结果。
typescript
/* 更新 onload 事件处理函数 */
window.onload = () => {
/* 在「设定相机」步骤中建立的相机的引用。 */
const cam = createVitalSignCamera({ isActive: true, config, userInfo })
// ...
/* 新增或更新 onVideoFrameProcessed 回呼函数 */
cam.onVideoFrameProcessed = (event: VideoFrameProcessedEvent) => {
// ...
/* 取得侦测到的标准化人脸框结果并将其列印到控制台 */
const facebox = event.facebox;
console.log(`Normalized Face Box: xCenter=${facebox?.xCenter}, yCenter=${facebox?.yCenter}, width=${facebox?.width}, height=${facebox?.height}`);
}
}js
/* 更新 onload 事件处理函数 */
window.onload = () => {
/* 在「设定相机」步骤中建立的相机的引用。 */
const cam = createVitalSignCamera({ isActive: true, config, userInfo })
// ...
/* 新增或更新 onVideoFrameProcessed 回呼函数 */
cam.onVideoFrameProcessed = (event) => {
// ...
/* 取得侦测到的标准化人脸框结果并将其列印到控制台 */
const facebox = event.facebox;
console.log(`Normalized Face Box: xCenter=${facebox.xCenter}, yCenter=${facebox.yCenter}, width=${facebox.width}, height=${facebox.height}`);
}
}