Class LeiaSDK
- java.lang.Object
-
- com.leia.sdk.LeiaSDK
-
public class LeiaSDK extends Object
LeiaSDK is the main entry point into CNSDK Java API.It's designed to be initialized once at the start of an app using a static method
createSDK(InitArgs)
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LeiaSDK.Delegate
LeiaSDK delegate.static class
LeiaSDK.InitArgs
Initialization arguments forcreateSDK(InitArgs)
.static class
LeiaSDK.ML
ML component.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
burnCameraExtrinsics(int cameraId, float thetaXFpc, float thetaYFpc, float thetaZFpc)
boolean
burnDisplayConfig(float slant, float pitch, float phc, float dOverN, float n, float actCoef)
Burn display config to displayconfig serviceboolean
burnDisplayConfig(float slant, float pitch, float phc, float dOverN, float n, float actCoef, float thetaX, float thetaY, float thetaZ)
static LeiaSDK
createSDK(LeiaSDK.InitArgs initArgs)
Create and start initialization of a LeiaSDK instance.void
enable3D(boolean shouldEnable)
Toggle the 3D mode.void
enableBacklight(boolean shouldEnable)
Deprecated.Useis3DEnabled()
boolean
enableFaceTracking(boolean enable)
Create or destroy the face tracking.void
enableNoFaceMode(boolean enable)
Toggle the no-face mode.boolean
getBacklight()
Deprecated.Useis3DEnabled()
Config
getConfig()
Deprecated.Use the Config class directlyFaceTrackingRuntime
getFaceTrackingRuntime()
Get current face tracking runtime.static LeiaSDK
getInstance()
Get the current LeiaSDK instance.static LegalOrientations
getLegalOrientations(Context context)
LeiaSDK.ML
getML()
Get the ML component.static String
getNaturalOrientation(Context context)
int
getOrientation()
Get the current orientation of the device.Vector3
getPrimaryFace()
Get the current predicted primary face.SharedCameraSink
getSharedCameraSink()
Get SharedCameraSink instance.Vector3
getTrackingCameraRotation()
Get tracking camera rotation in degreesboolean
is3DEnabled()
Check whether the 3D mode is enabled.static boolean
isDeviceSupported(Context context)
Check if the current device is supported.boolean
isFaceTrackingEnabled()
Check if face tracking is initialized.static boolean
isFaceTrackingInService(Context context)
Deprecated.static boolean
isFaceTrackingRuntimeSupported(FaceTrackingRuntime runtime, Context context)
Check if a particular face tracking runtime is supported by SDK.boolean
isFaceTrackingStarted()
Check whether face tracking is started.boolean
isInitialized()
Check if LeiaSDK is initialized.static boolean
isLicenseRequired(Context context)
Check if the current CNSDK build requires valid license.static void
limitOrientations(Activity activity, LegalOrientations legalOrientations)
void
onPause()
Notify LeiaSDK about activity entering background.void
onResume()
Notify LeiaSDK about activity entering foreground.void
setConfig(Config config)
Deprecated.Use the Config class directlyvoid
setDefaultFacePosition(Vector3 position)
void
setFaceTrackerConfiguration(boolean leftEye, boolean rightEye)
Set tracker to track individual eyes or center of facevoid
setFaceTrackingCaptureLux(boolean enable)
Toggle face tracking lux capture.void
setFaceTrackingFrameListener(HeadTrackingFrameListener listener)
Set face tracking frame listener.void
setFaceTrackingProfiling(boolean enable)
Toggle face tracking profiling.void
setFaceTrackingRuntime(FaceTrackingRuntime runtime)
Set current face tracking runtime.void
setFaceTrackingUseSharedCameraSink(boolean enable)
Configure face tracking to use the shared camera sink.void
setNoFaceModeTimeThreshold(double timeThresholdSeconds)
Set no-face mode time threshold.void
setTrackingCameraRotation(float thetaX, float thetaY, float thetaZ)
Set tracking camera rotation in degreesvoid
setUserIpd(float userIpd)
Optionally set user IPD in millimeters.static void
shutdownSDK()
Deinitialize and destroy the current LeiaSDK instance.void
startFaceTracking(boolean start)
Start or stop the face tracking.
-
-
-
Method Detail
-
getSharedCameraSink
@Nullable public SharedCameraSink getSharedCameraSink()
Get SharedCameraSink instance.LeiaSDK owns instance, don't try to release it.
Valid only if LeiaSDK initialized with
LeiaSDK.InitArgs.useSharedCameraSink
set to true.
-
isInitialized
public boolean isInitialized()
Check if LeiaSDK is initialized.- See Also:
createSDK(InitArgs)
-
onResume
public void onResume()
Notify LeiaSDK about activity entering foreground.Needs to be called only by the user that did not provide either app or activity in
LeiaSDK.InitArgs
.
-
onPause
public void onPause()
Notify LeiaSDK about activity entering background.Needs to be called only by the user that did not provide either app or activity in
LeiaSDK.InitArgs
.
-
getConfig
@NonNull public Config getConfig()
Deprecated.Use the Config class directlyGet the display config.- Throws:
NativeError
- if LeiaSDK is not initialized
-
setConfig
public void setConfig(Config config)
Deprecated.Use the Config class directlySet the display config.- Throws:
NativeError
- if LeiaSDK is not initialized
-
isFaceTrackingInService
@Deprecated public static boolean isFaceTrackingInService(Context context)
Deprecated.Deprecated. UsegetFaceTrackingRuntime()
instead.
-
isFaceTrackingRuntimeSupported
public static boolean isFaceTrackingRuntimeSupported(FaceTrackingRuntime runtime, Context context)
Check if a particular face tracking runtime is supported by SDK.
-
setFaceTrackingRuntime
public void setFaceTrackingRuntime(FaceTrackingRuntime runtime)
Set current face tracking runtime. This call has no effect if \p runtime is not supported.- See Also:
#isFaceTrackingRuntimeSupported(FaceTrackingRuntime)
-
getFaceTrackingRuntime
public FaceTrackingRuntime getFaceTrackingRuntime()
Get current face tracking runtime.
-
setFaceTrackingUseSharedCameraSink
public void setFaceTrackingUseSharedCameraSink(boolean enable)
Configure face tracking to use the shared camera sink.Face tracking must be re-enabled to apply changes.
Shared camera sink is supported only by in-app face tracking runtime.
Use
getSharedCameraSink()
to get the shared camera sink instance.
-
setFaceTrackingFrameListener
public void setFaceTrackingFrameListener(@Nullable HeadTrackingFrameListener listener)
Set face tracking frame listener.Can be called any time, even before LeiaSDK is initialized.
-
enableFaceTracking
public boolean enableFaceTracking(boolean enable)
Create or destroy the face tracking.- Throws:
NativeError
- if called before LeiaSDK is initialized
-
isFaceTrackingEnabled
public boolean isFaceTrackingEnabled()
Check if face tracking is initialized.
-
startFaceTracking
public void startFaceTracking(boolean start)
Start or stop the face tracking.
-
setFaceTrackerConfiguration
public void setFaceTrackerConfiguration(boolean leftEye, boolean rightEye)
Set tracker to track individual eyes or center of face
-
setUserIpd
public void setUserIpd(float userIpd)
Optionally set user IPD in millimeters.
-
burnDisplayConfig
public boolean burnDisplayConfig(float slant, float pitch, float phc, float dOverN, float n, float actCoef)
Burn display config to displayconfig service
-
burnDisplayConfig
public boolean burnDisplayConfig(float slant, float pitch, float phc, float dOverN, float n, float actCoef, float thetaX, float thetaY, float thetaZ)
-
burnCameraExtrinsics
public boolean burnCameraExtrinsics(int cameraId, float thetaXFpc, float thetaYFpc, float thetaZFpc)
-
setTrackingCameraRotation
public void setTrackingCameraRotation(float thetaX, float thetaY, float thetaZ)
Set tracking camera rotation in degrees
-
getTrackingCameraRotation
public Vector3 getTrackingCameraRotation()
Get tracking camera rotation in degrees
-
enableNoFaceMode
public void enableNoFaceMode(boolean enable)
Toggle the no-face mode.When this mode enabled, the 3D mode is automatically disabled by any active InterlacedSurfaceView if there is no face detected for the "no-face mode time threshold" seconds (see
setNoFaceModeTimeThreshold(double)
). As soon as a face is detected, the 3D mode turns back on.Enabled by default.
-
setNoFaceModeTimeThreshold
public void setNoFaceModeTimeThreshold(double timeThresholdSeconds)
Set no-face mode time threshold.
-
isFaceTrackingStarted
public boolean isFaceTrackingStarted()
Check whether face tracking is started.
-
enable3D
public void enable3D(boolean shouldEnable)
Toggle the 3D mode.
-
is3DEnabled
public boolean is3DEnabled()
Check whether the 3D mode is enabled.
-
getOrientation
public int getOrientation()
Get the current orientation of the device.
-
setFaceTrackingProfiling
public void setFaceTrackingProfiling(boolean enable)
Toggle face tracking profiling.
-
setFaceTrackingCaptureLux
public void setFaceTrackingCaptureLux(boolean enable)
Toggle face tracking lux capture.
-
getPrimaryFace
@Nullable public Vector3 getPrimaryFace()
Get the current predicted primary face. Null returned if none is detected.- Throws:
NativeError
- if called before LeiaSDK is initialized
-
setDefaultFacePosition
public void setDefaultFacePosition(@Nullable Vector3 position)
-
getML
@Nullable public LeiaSDK.ML getML()
Get the ML component.Returns null if CNSDK compiled without ML support.
-
isLicenseRequired
public static boolean isLicenseRequired(Context context)
Check if the current CNSDK build requires valid license. InitArgs#licenseKey must be specified if the license is required.
-
createSDK
@NonNull public static LeiaSDK createSDK(LeiaSDK.InitArgs initArgs) throws Exception
Create and start initialization of a LeiaSDK instance. Initialization process is asynchronous: LeiaSDK connects to a bunch of services.There are two ways to know whether LeiaSDK is fully initialized:
- poll
isInitialized()
- Android processes service connections on the main looper, so LeiaSDK will never be initialized if the scope in which createSDK is called never ends.
- get notified via
LeiaSDK.Delegate.didInitialize(LeiaSDK)
Application.onCreate()
. The second best place is the main activity'sActivity.onCreate(Bundle)
.- Returns:
- a LeiaSDK instance
- Throws:
Exception
- If an initialization error occurred. In this case, LeiaSDK and most of its components are not going to work.
- poll
-
shutdownSDK
public static void shutdownSDK()
Deinitialize and destroy the current LeiaSDK instance.
-
getInstance
@Nullable public static LeiaSDK getInstance()
Get the current LeiaSDK instance. Do not cache the returned reference. In other words, the returned reference should not outlive the caller's scope.
-
getLegalOrientations
@Nullable public static LegalOrientations getLegalOrientations(Context context)
-
limitOrientations
public static void limitOrientations(@NonNull Activity activity, @Nullable LegalOrientations legalOrientations)
-
enableBacklight
@Deprecated public void enableBacklight(boolean shouldEnable)
Deprecated.Useis3DEnabled()
-
getBacklight
@Deprecated public boolean getBacklight()
Deprecated.Useis3DEnabled()
-
isDeviceSupported
public static boolean isDeviceSupported(Context context)
Check if the current device is supported.
-
-