Skip to content

Create Vital Sign Camera

As described in Vital Sign Camera, in Vitals™ SDK, we provide a tailor-made camera component, named Vital Sign Camera.

Target SDK

JavaScript
React
Vue
Flutter
ReactNative
Android
iOS

TIP

You can refer to the sample code and the API Reference for more details. Most related API(s) include: createVitalSignCamera, VitalSignCameraCreationProps, and VitalSignEngineConfig.

To setup the Vital Sign Camera, declare the video HTML element. For example:

html
<!-- Vital Sign Camera -->
<video id="video" autoplay="true" playsinline></video>

If you are using the vital-sign-camera.umd-X.X.X.js script for SDK installation (as mentioned in Downloads), in your JavaScript file, import the module components by, for example:

js
const { createVitalSignCamera, ServerId } = VitalSignCameraUMD;

Else, in your TypeScript or JavaScript file:

typescript
import { createVitalSignCamera, VitalSignEngineConfig, ServerId } from "ts-vital-sign-camera";
js
import { createVitalSignCamera, ServerId } from "ts-vital-sign-camera";

Make sure the package name is the same as what is described in the package.json file. You may also need to add other imports to this line yourself later.

Create the Vital Sign Camera component and bind it to the video element:

typescript
/* Vitals™ Cloud Service Config */
const config : VitalSignEngineConfig = {
    serverId: ServerId.AwsProdEnterprise,
    apiKey: "__YOUR_API_KEY__",
}

window.onload = () => {
    /* Create and initialize Vital Sign Camera */
    const video = document.querySelector("video")!;
    const cam = createVitalSignCamera({ isActive: true, config });
    cam.bind(video);
}
js
/* Vitals™ Cloud Service Config */
const config = {
    serverId: ServerId.AwsProdEnterprise,
    apiKey: "__YOUR_API_KEY__",
}

window.onload = () => {
    /* Create and initialize Vital Sign Camera */
    const video = document.querySelector("video");
    const cam = createVitalSignCamera({ isActive: true, config });
    cam.bind(video);
}

In TypeScript, you might get an error saying that userInfo is missing. You can add it by following the Acquire Health Profile guide.

Resize the camera preview in the CSS file in case it is too large for you:

css
#video {
    width: 640px;
    height: 480px;
}

TIP

In the above example, the string __YOUR_API_KEY__ should be replaced by your own API Key. Please contact us to obtain your API Key, which is the credential for accessing the Vitals™ Cloud Service.