Skip to main content

Capture SDK Methods

create

Description:

You need to call this method before using the SDK. It will return an instance of it

Parameters:

NameTypeDescription
langstringLanguage (en or es)
translationsobjectThe object with the translations. (Ask support) (optional)
opencvURLstringThe URL of opencv (optional)
facefinderURLbooleanThe URL of facefinder (optional)

Returns

  • Object:

    The SDK instance

Example:

 const onBoarding = window.OnBoarding.createSession(countryCode)
// use instance
await onBoarding.warmup()
});

warmup

Description: This warmup is the function that prepare the autodetect model. You need to call it before renderCapture method.

Returns: Promise

renderCapture

Description:

This method is gonna render the Camera with the autodetect and notifications in the browser. You need to handle the image and send it to the Incode Service and handle errors

Parameters:

NameTypeDescription
typestringtype of captured image: One of this: front, back, selfie. document, passport
containerHTMLElement
optionsObjectobjectoptions object

Options:

NameTypeDescription
onSuccessfunctionCallback when the detect was success. In the first param it's gonna have an object with {imageBase64, blob, encryptedImage, src}. imageBase64 is the captured image in base64, blob is the image as a Blob, encryptedImage (only selfie) This is the encryptedImage, src is the image for showing in a img element
onLogfunctionA function with a logger
permissionMessageStringThe message in the permission screen. Default: "Press "Allow" to continue."
permissionBackgroundColorStringThe background of permissions screen. Default: "#696969
timeoutnumberThe timeout in miliseconds for looking for a face (only if type = 'selfie')
streamMediaStreamIf you send stream it won't ask again to the user. This is an advanced option. Optional
nativeCamerabooleanThis is only for document option. If set to true, it's gonna use the native camera for the capture (default: false)

Example:

onBoarding.renderCamera('front', container, {
onSuccess: async images => {
const { imageBase64, blob, src } = images;
const frontIdResponse = await uploadFrontId(blob);
validateFrontIdResponse(frontIdRespone);
changeStep('back');
},
onError: error => log(error),
});