取得人臉偵測結果
目標 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}`);
}
}