Skip to content

取得扫描状态

为了获得良好的使用者体验并让使用者了解扫描进度,您应该在使用者介面上视觉化扫描状态。 Vitals™ SDK 透过 onVideoFrameProcessed 回呼函数提供扫描阶段和剩余时间(以秒为单位)。您可以观察其中的变化并相应地更新使用者介面。

目标 SDK

JavaScript
React
Vue
Flutter
ReactNative
Android
iOS

TIP 提示

您可以参考 示例程式码API 参考 以了解更多详情。相关 API 包括:VideoFrameProcessedEventScanResultGetHealthStage

若要取得扫描状态,包括扫描阶段和剩余秒数,请执行下列操作:

typescript
/* 更新 onload 事件处理函数 */
window.onload = () => {
    /* 在「设定相机」指南中所建立的相机引用 */
    const cam = createVitalSignCamera({ isActive: true, config, userInfo })

    /* 更新 onVideoFrameProcessed 回呼函数 */
    cam.onVideoFrameProcessed = (event: VideoFrameProcessedEvent) => {
        // ...

        /* 新增此函数以列印扫描状态。 */
        console.log(`扫描阶段=${event.healthResult?.stage}, 剩余秒数=${event.healthResult?.remainingTime}`);
    }
}
js
/* 更新 onload 事件处理函数 */
window.onload = () => {
    /* 在「设定相机」指南中所建立的相机引用 */
    const cam = createVitalSignCamera({ isActive: true, config, userInfo })

    /* 更新 onVideoFrameProcessed 回呼函数 */
    cam.onVideoFrameProcessed = (event) => {
        // ...

        /* 新增此函数以列印扫描状态。 */
        console.log(`扫描阶段=${event.healthResult?.stage}, 剩余秒数=${event.healthResult?.remainingTime}`);
    }
}