Stop a Scan
Target SDK
TIP
You can refer to the sample code and the API Reference for more details. Most related API(s) include: VitalSignCameraInterface
.
Explicitly stopping a scan is required only when you want to handle customized errors (e.g., conditions check failed during scan). When an error is thrown from the Vitals™ SDK via the onVideoFrameProcessed
callback function, or when the analysis stage completes and returns the health results, the Vital Sign Camera will automatically stop scanning and revert to the Idle
stage, you do not have to explicitly call the stopScanning()
API in those cases.
Although you do not need to explicitly call the stopScanning()
API of the Vital Sign Camera component to stop a scan in general, you can still call it, make sure you only call it when the vital sign camera is not in the Idle
stage, for example:
/* Update the onload event handler function */
window.onload = () => {
/* A reference of the camera that should have been created in the "Camera Setup" step. */
const cam = createVitalSignCamera({ isActive: true, config, userInfo })
/* Update the onVideoFrameProcessed callback function */
cam.onVideoFrameProcessed = (event : VideoFrameProcessedEvent) => {
// ...
/* NOT REQUIRED - Explicitly call stopScanning() if there is an error */
if (event.healthResult?.error && event.healthResult?.stage !== GetHealthStage.Idle) {
cam.stopScanning();
}
}
}
/* Update the onload event handler function */
window.onload = () => {
/* A reference of the camera that should have been created in the "Camera Setup" step. */
const cam = createVitalSignCamera({ isActive: true, config, userInfo })
/* Update the onVideoFrameProcessed callback function */
cam.onVideoFrameProcessed = (event) => {
// ...
/* NOT REQUIRED - Explicitly call stopScanning() if there is an error */
if (event.healthResult?.error && event.healthResult?.stage !== GetHealthStage.Idle) {
cam.stopScanning();
}
}
}