Measurement preparation
After successfully installing, initializing and optionally configuring the SDK, your app should be ready to start the video measurement.
Before starting the measurement, the user should be instructed to keep a stable position without talking and changing the facial expression.
Initial conditions
After initialization, the SDK will start to analyze the video stream from the camera.
In order for the measurement to begin, the user needs to locate their face in the middle of the screen, in good lighting conditions. The embedded user interface displays face positioning hints, but you can also use the GetFaceState() and GetNormalizedFaceBbox() methods to check the current face position.
import 'package:shenai_sdk/shenai_sdk.dart';
// Get the current face state
final faceState = await ShenaiSdk.getFaceState();
switch (faceState) {
case FaceState.ok:
print("Face detected and centered");
break;
case FaceState.notCentered:
print("Face detected but not centered");
break;
case FaceState.tooClose:
print("Face is too close");
break;
case FaceState.tooFar:
print("Face is too far");
break;
case FaceState.notVisible:
print("Face is not visible");
break;
case FaceState.turnedAway:
print("Face turned away");
break;
case FaceState.unknown:
print("Unknown face state");
break;
}
// Get the normalized bounding box of the face
final bbox = await ShenaiSdk.getNormalizedFaceBbox();
if (bbox != null) {
print("normalized face bounding box: ${bbox.x} ${bbox.y} ${bbox.width} ${bbox.height}");
}