Initialization
Before starting the video measurement, you'll need to initialize the SDK.
Under the hood that step verifies the license, connects to a native platform camera device and sets up rendering for real-time feedback. The app must have camera permissions before this step.
You'll need to provide an API key - see Authorization for more information.
- Flutter
- Android
- Web
API_KEY = ""
USER_ID = ""
final _initResult = await ShenaiSdk.initialize(API_KEY, USER_ID);
Error handling
You should check if the initialization was successful before proceeding further.
Possible errors at this stage include:
INVALID_API_KEY
- the provided API key is malformed or inactiveCONNECTION_ERROR
- there is a problem with network connection to the licensing serverINTERNAL_ERROR
- other errors such as missing camera permissions
- Flutter
- Android
- Web
enum InitializationResult {
success,
failInvalidApiKey,
failConnectionError,
failInternalError,
fail
}
If the SDK has been successfully initialized, repeated calls to initialize
will immediately return success - to start a new session first deinitialize the SDK.
Configuration
The SDK can be configured at the initialization stage with certain functionalities turned on or off.
disableOverlayRendering
(false
by default) allows to hide the face mesh/blood visualization
isCameraPreviewMirror
(true
by default) determines if the camera preview is displayed in mirrored mode
- Flutter
- Android
- Web
final _initResult = await ShenaiSdk.initialize(API_KEY, USER_ID,
disableOverlayRendering: true,
isCameraPreviewMirror: true
);
Connecting the rendering surface
Initializing the SDK creates a rendering target for displaying the camera preview, optionally including a 3d mask preview and real-time blood pulsation visualization.
- Flutter
- Android
- Web
Obtain the rendering texture identifier from the SDK:
final _displayTexture = await ShenaiSdk.createDisplayTexture();
You can then render it in the Flutter tree using the Texture
widget.
Texture(textureId: _displayTexture)
Deinitialization
After finishing using the SDK you should deinitialize it - that will free up any allocated resources and disconnect from the camera.
- Flutter
- Android
- Web
ShenaiSdk.deinitialize();