API Documentation
This page contains all LIQA API methods
Preparation stage
Create LIQA instance class
checkCameraAvailable: Promise<void>
The checkCameraAvailable
method allows to validate if camera and browser are correctly setup and suitable for launching the LIQA.
This method requires access to the device camera and will launch (and then stop) the camera to check that all parameters are correctly setup and all API methods are available in current browser. We recommend calling this method for every start before liqa.init
.
We highly recommend to setup a .catch operation on liqa.checkCameraAvailable
method with some resulting warning for the end-user. The detected issues with LIQA start might be critical and it is better to recommend your user to try one of stable browsers (e.g. Chrome on Android, Safari on iOS) / check their permissions on camera access for different apps, etc.
Unfortunately, LIQA can not detect the exact reason why the system fails to provide the full necessary access to camera and its methods.
load: Promise<void>
The load
method fetches model weights files and optionally compiles AI models for the device hardware. You may turn off a model compilation during the load
method, and in this case, the compilation will take time during the first frame of a video stream.
The duration of fetching model weights depends on the Internet connection speed. For example, it requires only 0.3s at 30Mbps;
The model compilation is computationally intensive. It requires different times depending on device hardware: from ~1s on modern devices to more than 10s on laptops or old devices.
init: void
Create config object with inner settings (see Config description):
The init
method creates a canvas for video rendering in provided DOM container.
Image collection session
play: Promise<void>
The play
method starts live capture via the camera and the calculation of AI models.
You can call methods
one by one, without waiting (promise/then or await construction) for their completion. In this case, they will be executed sequentially.
It allows to put the load
method in another component of your application.
captureSelfie: Promise<void>
The captureSelfie
method sends a request to capture selfie.
Note: aftercaptureSelfie
method, LIQA will stop the stream. You can continue stream by callingliqa.play()
after receiving a selfie image.
Note: This method will be called automatically, if autoSelfieCapture
parameter value in config.json
was set to true
Note: Promise rejection if the play
method has not been finished by now.
stop: void
The stop
method stops the camera's live capture and the calculation of AI models.
You can call the stop
method urgently without waiting for the play
method to complete. The methods will be executed sequentially.
unmount: void
The unmount
method destroys the canvas and all of the elements generated during the LIQA work inside of the DOM container provided in the init
method.
After unmounting of LIQA, play
, stop
, captureSelfie
methods are not available. To start LIQA again call the init
method.
exit: void
The exit
method removes web-workers, clears variables, and frees memory buffers allocated for LIQA.
After exiting, all methods are not available. To start LIQA again call the load
method.
Last updated