Skip to Content
Video measurementPreparation

Measurement preparation

Ask the person to face the camera with their face centered and evenly lit. During the scan, ask them to hold still, keep a steady expression, and avoid talking.

After initialization, the embedded UI guides the person into position and enables Start when the SDK is ready. If you use the built-in controls, you can go straight to tracking the measurement.

Face positioning

If your app gives its own positioning guidance, use the face state to decide what to show as frames arrive.

Face stateSuggested guidance
Not visibleAsk the person to bring their face into view.
Not centeredAsk them to center their face in the frame.
Too farAsk them to move closer.
Too closeAsk them to move back.
Turned awayAsk them to look straight at the camera.
OKThe face is in position. Clear the positioning prompt.
UnknownWait for another frame before giving a positioning prompt.

To draw a box around the face, read the bounding box when one is available. Its top-left corner (x, y) and size (width, height) are fractions of the video frame’s width and height. If your preview is cropped or mirrored, apply the same transformation to the box.

const faceState = shenaiSDK.getFaceState() const faceBox = shenaiSDK.getNormalizedFaceBbox()

Measurement conditions

Before a scan, the SDK checks the person’s position, movement, and lighting. A blocking condition prevents the scan from starting until the check passes. A warning gives the person a chance to make an adjustment and still allows the scan to start.

ConditionWhen the check failsDefault
FacePositionThe face is missing or outside the required position or angle.Blocking
ForeheadVisibleThe camera cannot see the forehead clearly.Warning
SufficientLightLevelThere is too little light on the face overall.Warning
EvenLightingSome parts of the face are much darker than others.Warning
NoBacklightA bright light behind the person makes the face hard to see.Warning
FaceStableThe person’s face is moving too much.Warning
DeviceStableThe device is moving too much.Warning
GlassesNotDetectedThe SDK detects glasses on the face.Off

To guide someone during positioning, read the current unmet condition. For example, suggest more light when the SDK reports insufficient lighting. Clear the prompt when the SDK reports no unmet condition.

const condition = shenaiSDK.getCurrentViolatedMeasurementEnvironmentCondition() const needsMoreLight = condition === shenaiSDK.MeasurementEnvironmentCondition.SUFFICIENT_LIGHT_LEVEL

To change these defaults, configure the blocking and warning lists.

Starting, stopping, and resetting a scan

In positioning mode, the SDK tracks the face while it waits for a start request. If your app has its own Start button, update it as frames arrive. Enable it only when the SDK’s readiness check returns true. Readiness takes the required models and the blocking conditions above into account. A warning can still be present when Start is enabled. The SDK ignores an early start request.

To start automatically when the conditions are met, select measure mode at initialization or switch to it at runtime.

Stop cancels a timed scan. In continuous mode, it asks the SDK to finish and produce results. Reset clears the current scan and returns to positioning in the same SDK session. Read any results you want to keep before resetting.

if (shenaiSDK.isReadyToStartMeasurement()) { shenaiSDK.startMeasurement() }

For Stop, call shenaiSDK.stopMeasurement(). For Retry, call shenaiSDK.resetMeasurementSession().

For direct mode control, read the current mode with shenaiSDK.getOperatingMode() and change it with shenaiSDK.setOperatingMode(mode).

If the operating mode reports system overloaded, wait for the SDK to recover before retrying. The SDK sets this mode automatically.

Once a scan starts, track its progress and read live metrics.