To help you get started, we have provided an example for the popular Vue.js framework. Follow the steps below to run the example:
- Ensure you have the necessary prerequisites installed, such as Node.js and npm.
- Clone the repository and navigate to the project directory.
- Run the example using the following command, replacing
<path_to_capture_library>
and<path_to_license_file>
with the actual paths to your capture library and license file:
./run_example vue <path_to_capture_library> <path_to_license_file>
This command will set up and run the example application, allowing you to see the document capture component in action within a Vue.js environment.
Feel free to explore and modify the example to suit your needs.
Install node js latest version for your system
Install package in your app (replace ./idlive-document-capture-web.tgz
with path to provided archive file)
npm i idlive-document-capture-web file:./idlive-document-capture-web.tgz
Import the component into your app
import 'idlive-document-capture-web';
Add the component's html tag to the place on the page where you want to display the video from the camera
<idlive-document-capture></idlive-document-capture>
NOTE: The component occupies 100% of the parent's element. Make sure it has a non-zero height and width
The component has the following optional attributes:
mask_hidden
- do not show the document maskauto_capture_disabled
- disable auto capture after document detectionauto_close_disabled
- do not close camera after taking a photoaudio_enabled
- request media stream with audiopayload_size
- size of produced payload, available values: "normal" (default) and "small"device_id
- device ID of the specific camera to be openedcapture_mode
- capture mode, available values: "encryptedPayload" (default) and "singleImage"
<idlive-document-capture mask_hidden></idlive-document-capture>
You can interact with the component using the following methods:
openCamera
- open camera and show videotakePhoto
- take photocloseCamera
- close camerasetEncryptionKey
- set encryption keysetLicense
- set license
const idliveDocCapture = document.querySelector('idlive-document-capture');
idliveDocCapture.openCamera();
The component emits the following events:
initialize
- the component is initialized and ready to open camerabeforeOpen
- the camera starts to openopen
- the camera is open and element is ready to show videodocumentDetection
- document detection resultbeforeCapture
- the capture process startedcapture
- the capture process completedclose
- the camera was closederror
- a critical error occurred
idliveDocCapture.addEventListener('initialize', (event) => {
// the component is ready, now you can open camera
});
const { photo, encryptedFile } = event.detail[0];
if (!photo) {
return;
}
const photoData = new FormData();
photoData.append('file', photo);
const idldServerUrl = 'https://IDLD_SERVER_URL:PORT';
const idldUrlWithParams = `${idldServerUrl}/check_liveness_file?pipelines=default-sr,default-pc,default-ps`;
const iadServerUrl = 'https://IAD_SERVER_URL:PORT';
const iadUrlWithParams = `${iadServerUrl}/check_capture_liveness`;
this.isCapturing = false;
this.isResultsLoading = true;
const idldRequest = fetch(idldUrlWithParams, {
method: "post",
body: photoData
}).then(response => response.json());
const iadRequest = fetch(iadUrlWithParams, {
method: "post",
headers: { 'Content-Type': 'application/octet-stream' },
body: encryptedFile
}).then(response => response.json());
Promise.all([idldRequest, iadRequest])
.then(([idldResult, iadResult]) => {
// process results from the server
})
.catch(e => {
// error
});