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 state | Suggested guidance |
|---|---|
| Not visible | Ask the person to bring their face into view. |
| Not centered | Ask them to center their face in the frame. |
| Too far | Ask them to move closer. |
| Too close | Ask them to move back. |
| Turned away | Ask them to look straight at the camera. |
| OK | The face is in position. Clear the positioning prompt. |
| Unknown | Wait 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.
| Condition | When the check fails | Default |
|---|---|---|
FacePosition | The face is missing or outside the required position or angle. | Blocking |
ForeheadVisible | The camera cannot see the forehead clearly. | Warning |
SufficientLightLevel | There is too little light on the face overall. | Warning |
EvenLighting | Some parts of the face are much darker than others. | Warning |
NoBacklight | A bright light behind the person makes the face hard to see. | Warning |
FaceStable | The person’s face is moving too much. | Warning |
DeviceStable | The device is moving too much. | Warning |
GlassesNotDetected | The 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_LEVELTo 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.