Video measurement
Measurement

During the measurement

After the measurement has started, you can monitor the stage and progress of the measurement.

Checking the measurement state

To see what is happening underneath you can call the getMeasurementState() method. It returns the following enum informing you about the state of the measurement.

enum MeasurementState {
  notStarted,                       // Measurement has not started yet
  waitingForFace,                   // Waiting for face to be properly positioned in the frame
  runningSignalShort,               // Measurement started: Signal is too short for any conclusions
  runningSignalGood,                // Measurement proceeding: Signal quality is good
  runningSignalBad,                 // Measurement stalled due to poor signal quality
  runningSignalBadDeviceUnstable,   // Measurement stalled due to poor signal quality (caused by unstable device)
  finished,                         // Measurement has finished successfully
  failed,                           // Measurement has failed
}

In particular, you should wait for Finished or Failed values, because they indicate that the measurement has concluded.

Tracking the measurement progress

To check the progress of the whole measurement you can call the getMeasurementProgressPercentage() method, returning a floating point number between 0 and 100.

Real-time metrics

During the measurement you can query the SDK for real-time metrics. These metrics are updated every second.

Heart rate

You can query the real-time heart rate based on either the last 10 or 4 seconds of the measurement. The provided value is the average heart rate over the specified time interval and is expressed in beats per minute (BPM), rounded to the nearest integer.

var hr = await ShenAiSdk.getHeartRate10s();
var hr = await ShenAiSdk.getHeartRate4s();

The 10 seconds value will be more stable (like a value displayed on a typical smartwatch), while the 4 seconds value will more accurately depict moment-to-moment fluctuations of the heart rate.

HRV and Cardiac Stress

You can query the SDK for real-time Heart Rate Variability and Cardiac Stress values. You can choose the period over which the metrics are calculated. Note that shorter time periods may lead to unstable values, but may be useful in biofeedback scenarios.

See the Measurement Results section for details on the returned structure shape. Note that Breathing Rate and Blood Pressure will be null in the result of getRealtimeMetrics.

var metrics = await ShenaiSDK.getRealtimeMetrics(30.0);

Intervals

You can also query the SDK for real-time heartbeat intervals. The values returned are in milliseconds and are rounded to the nearest integer.

Signal quality

You can query the SDK for real-time signal quality - the value can be used to provide additional feedback to the user. A higher value means a better signal quality.

var signal_quality = await ShenAiSdk.getCurrentSignalQualityMetric();

Measurement success

When the Shen.AI SDK engine enters the Finished state it means that the measurement has concluded and computed metrics are available.

See Results to see how to access the results.