Appearance
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 Modes for more information about measurement modes.
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 mode (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:
TypeScript
import {
SessionBuilder
} from 'binah-react-native-sdk';
try {
const session = await SessionBuilder.faceSession({licenseKey: "<ENTER_YOUR_LICENSE_KEY>"});
} catch (e) {
const exception = (e as HealthMonitorException)
console.log(`Error: ${exception?.code}`);
}
Waiting for the Session to Transition into ready State
The application can receive session state updates by using the useSessionState
hook:
TypeScript
import {
SessionState
} from 'binah-react-native-sdk';
const sessionState = useSessionState();
React.useEffect(() => {
if (sessionState == SessionState.READY) {
console.log("Session is ready to start measuring");
}
}, [sessionState])
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
TypeScript
try {
var measurementDuration = 60;
await session.start(measurementDuration);
} on HealthMonitorException catch(e) {
const exception = (e as HealthMonitorException)
console.log(`Error: ${exception?.code}`);
}
Receiving Results During a Measurement
The application can receive instantaneous vital signs values by using useVitalSigns
hook:
TypeScript
import {
VitalSignTypes,
useVitalSigns
} from 'binah-react-native-sdk';
const vitalSign = useVitalSigns();
React.useEffect(() => {
// Handle vital sign result
}, [vitalSign]);
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.
TypeScript
try {
await session.stop();
} on HealthMonitorException catch(e) {
console.log(`Received Error. Domain: ${e.domain} Code: ${e.code}`);
}
Note
Calling thestop
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.
TypeScript
import {
VitalSignTypes,
useFinalResults
} from 'binah-react-native-sdk';
const finalResults = useFinalResults();
React.useEffect(() => {
// Handle the final results of the measurements
}, [finalResults]);
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.
TypeScript
await 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.