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 three measurements modes:

  • Face Measurement
  • Finger Measurement
  • Polar 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 Modes for more information about measurement modes.

Creating a Measurement Session

A session is an interface for performing vital sign measurements.

  • When creating a session, it is essential to define the measurement mode. The SDK supports three measurement modes:
    • Face Measurements (Front Camera): This mode utilizes the front camera for capturing face-related measurements.
    • Finger Measurements (Rear Camera): In this mode, the rear camera is used to take measurements from the user's finger.
    • Polar Measurements (External PPG Sensor): This mode enables measurements using the Polar Verity Sense sensor.
  • 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 mode (for example, 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.
Kotlin
try {
    val licenseDetails = LicenseDetails("<ENTER_YOUR_LICENSE_KEY>")
    val session = FaceSessionBuilder(applicationContext)
                    .withImageListener(this)
                    .withVitalSignsListener(this)
                    .withSessionInfoListener(this)
                    .build(licenseDetails)
} catch (e: HealthMonitorException) {
    Log.i("ERROR", "Received Error. Domain: ${e.domain} Code: ${e.errorCode}")
}
Java
try {
    LicenseDetails licenseDetails = new LicenseDetails("<ENTER_YOUR_LICENSE_KEY>");
    Session session = new FaceSessionBuilder(getApplicationContext())
                    .withImageListener(this)
                    .withVitalSignsListener(this)
                    .withSessionInfoListener(this)
                    .build(licenseDetails);
} catch (HealthMonitorException e) {
    Log.i("ERROR", "Received Error. Domain: "+ e.getDomain() +" Code: "+ e.getErrorCode());
}

Waiting for the Session to Transition into READY State

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

Kotlin
override fun onSessionStateChange(sessionState: SessionState) {
    runOnUiThread {
        if (sessionState == SessionState.READY) {
            Log.i("SESSION_STATE", "Session is ready to start measuring");
        }
    }
}
Java
@Override
public void onSessionStateChange(@NonNull SessionState sessionState) {
    runOnUiThread(() -> {
        if (state == SessionState.READY) {
            Log.i("SESSION_STATE", "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

Kotlin
try {
    val measurementDuration = 60
    session.start(measurementDuration)
} catch (e: HealthMonitorException) {
    Log.i("ERROR", "Received Error. Domain: ${e.domain} Code: ${e.errorCode}")
}
Java
try {
    long measurementDuration = 60;
    session.start(measurementDuration);
} catch (HealthMonitorException e) {
    Log.i("ERROR", "Received Error. Domain: "+ e.getDomain() +" Code: "+ e.getErrorCode());
}

Receiving Results During a Measurement

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

Kotlin
override fun onVitalSign(vitalSign: VitalSign) {
    // Handle vital sign result
}
Java
@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.

Kotlin
try {
    session.stop()
} catch (e: HealthMonitorException) {
    Log.i("ERROR", "Received Error. Domain: ${e.domain} Code: ${e.errorCode}")
}
Java
try {
    session.stop();
} catch (HealthMonitorException e) {
    Log.i("ERROR", "Received Error. Domain: "+ e.getDomain() +" Code: "+ e.getErrorCode());
}

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.

Kotlin
override fun onFinalResults(results: VitalSignsResults) {
    // Handle the final results of the measurements
}
Java
@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.

Kotlin
session.terminate()
Java
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.