Package com.leia.sdk

Class 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).

    • Method Detail

      • 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 directly
        Get the display config.
        Throws:
        NativeError - if LeiaSDK is not initialized
      • setConfig

        public void setConfig​(Config config)
        Deprecated.
        Use the Config class directly
        Set the display config.
        Throws:
        NativeError - if LeiaSDK is not initialized
      • 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:

        Should be called once, consecutive calls are ignored. The best place for this call is Application.onCreate(). The second best place is the main activity's Activity.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.
      • 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.
      • limitOrientations

        public static void limitOrientations​(@NonNull
                                             Activity activity,
                                             @Nullable
                                             LegalOrientations legalOrientations)
      • getNaturalOrientation

        @Nullable
        public static String getNaturalOrientation​(Context context)
      • isDeviceSupported

        public static boolean isDeviceSupported​(Context context)
        Check if the current device is supported.