Skip to content
On this page

Quick Start

This quick start guide describes the basic flow for measuring vital signs using Binah.ai SDK.

The SDK supports two measurements modes:

  • Face Measurement
  • Finger Measurement

Deprecation Warning

Finger measurements are deprecated and will be removed in future versions of Binah.ai's SDK.

A sample flow for face measurement follows. A similar flow can be applied for finger measurements. See Measurement Types for more information about measurement types.

Creating a Measurement Session

A session is an interface for performing vital sign measurements.

  • A session is established to calculate either face measurements using the front camera or a finger measurement using the rear camera, as defined during the session creation.
  • Only a single session can be created at any given time. Terminate the previous session before creating a new session.
  • When switching to a different measurement type (from face to finger, or from finger to face), the current session must be terminated, and a new session must be created.
  • A session is intended for a single user. When measuring the vital signs of another user, a new session must be created. See Demographic Info.

The following code can be used to create a session with the relevant parameters:

Note

  • For simplicity, the code sample below uses this (the current class) as the implementor of all the session builder listeners.
Dart
try {
    LicenseDetails licenseDetails = LicenseDetails("<ENTER_YOUR_LICENSE_KEY>");
    Session? session = await FaceSessionBuilder()
        .withImageDataListener(this)
        .withVitalSignsListener(this)
        .withSessionInfoListener(this)
        .build(licenseDetails);
} on HealthMonitorException catch(e) {
    print("Received Error. Domain: ${e.domain} Code: ${e.code}");
}

Waiting for the Session to Transition into ready State

The application can receive session state updates by implementing onSessionStateChange as part of SessionInfoListener.

Dart
@override
void onSessionStateChange(SessionState sessionState) {
    if (state == SessionState.ready) {
        print("Session is ready to start measuring");
    }
}

Note

For more information on session states and state transitions, see Session State section.

Starting a Measurement

A measurement can be started by calling the start method

Dart
try {
    var measurementDuration = 60;
    session.start(measurementDuration);
} on HealthMonitorException catch(e) {
    print("Received Error. Domain: ${e.domain} Code: ${e.code}");
}

Receiving Results During a Measurement

The application can receive instantaneous vital signs values by implementing onVitalSign as part of VitalSignsListener.

Dart
@override
 void onVitalSign(VitalSign vitalSign) {
    // Handle vital sign result
}

During the measurement, the instantaneous vital sign values are available only for specific vital signs, while the results of all vital signs are received once the measurement has been completed.

Note

For more information on receiving and handling vital sign information, see Vital Signs.

Stopping a Measurement

The measurement is stopped either after the measurement duration (provided in the start function) has ended, or when the stop method is called.

Dart
try {
    session.stop();
} on HealthMonitorException catch(e) {
    print("Received Error. Domain: ${e.domain} Code: ${e.code}");
}

Note

Calling the stop method initiates the calculation of the final results. See Vital Signs

Important

When the measurement stops, the session will transition to the stopping state.

The stopping state reflects that the session has initiated a stopping process that ends when the session state transitions to ready. At this point, a new measurement can be started.

Receiving Final Results

The application can receive final vital sign results and vital sign confidence levels by implementing onFinalResults as part of VitalSignsListener.

Dart
@override
void onFinalResults(VitalSignsResults results) {
    // Handle the final results of the measurements
}

The final results are computed when the session is in stopping state. For more information about receiving and handling the final results, see Vital Signs.

Terminating a Session

It is recommended to terminate the session whenever the measuring screen is not visible.

Dart
session.terminate();

Important

Terminating the current session is mandatory in order to create a new session. When calling terminate(), the session will transition to terminating state.

The terminating state means that the session has started a termination process that ends when the session state transitions to terminated.