API JS Component

Here you will find the complete API documentation.

Initialization options

On the script tag you can set some data attributes to define various options of the component.

<script src="https://idcapture.es/idcapture-latest.js" data-container="container" data-callback="initIdCapture" defer></script>

Options

Name Description Required
data-container DOM element to contain the component. Yes
data-callback Callback function for component control. Yes

Once initialized the component a Bidcapture object is returned to the callback function.

Callback function

You have to declare the callback function on window object.

<script>
    window.initIdCapture = function (Bidcapture) {
        Bidcapture.setSize(480,360);
        Bidcapture.setMode('REVDNI');
        Bidcapture.onMrzData = function (mrz_data) {    
            console.log(mrz_data);
        }
    };
</script>

Methods

enable()

Bidcapture.enable();    // Activate the component.

disable()

Bidcapture.disable();    // Deactivate the component.

setSize(width,height)

Bidcapture.setSize(480,360);    // Set the video webcam size.

setMode(mode, options)

Bidcapture.setMode('ANVDNI', options);    // Set the operating mode of the component.

setOutputMode(mode)

Bidcapture.setOutputMode('SERVER');    // Set the output mode of the component. SERVER draws received frames procesed by the server. CLIENT draws info without draw SERVER frames.

The options parameter must be a json string to pass information to the selected operating mode. Null by default.

Events

onConnect()

<script>
    window.initIdCapture = function (Bidcapture) {
        // onConnect fires when service is ready.
        Bidcapture.onConnect = function () {    
            Bidcapture.setMode('ANVDNI');
            Bidcapture.enable();
        }
    };
</script>

onCapture()

<script>
    window.initIdCapture = function (Bidcapture) {
        // onCapture fires when capture is received. ANVDNI and REVDNI modes.
        Bidcapture.onCapture = function (b64image) {
            console.log(b64image);
        }
    };
</script>

onMrzData()

<script>
    window.initIdCapture = function (Bidcapture) {
        // onMrzData fires on OCR results when MRZ is read. REVDNI mode.
        Bidcapture.onMrzData = function (data) {
            console.log(data);
        }
    };
</script>

onFaceData()

<script>
    window.initIdCapture = function (Bidcapture) {
        // onFaceData fires on OCR results when MRZ is read. BIOGEN and BIOREC modes.
        Bidcapture.onMrzData = function (data) {
            console.log(data);
        }
    };
</script>

Operating Modes

ANVDNI

This mode is used to capture front side of ID Card. It recognizes official ID templates. On capture fires the callback function bind to onCapture event that recives the base64 coded string of the captured image.

<script>
    window.initIdCapture = function (Bidcapture) {
        Bidcapture.setMode('ANVDNI');
        Bidcapture.onCapture = function (b64image) {    
            console.log(b64image);
        }
    };
</script>

REVDNI

This mode is used to capture back side of ID Card and to get data from OCR of the MRZ. It recognizes official ID templates. On capture fires the callback function bind to onCapture event that recives the base64 coded string of the captured image. When the OCR recognize the MRZ data fires the callback function bind to onMrzData event that recives a javascript object with the captured data.

<script>
    window.initIdCapture = function (Bidcapture) {
        Bidcapture.setMode('REVDNI');
        Bidcapture.onCapture = function (b64image) {    
            console.log(b64image);
        }
        Bidcapture.onMrzData = function (dataObj) {    
            console.log(dataObj);
        }
    };
</script>

The following is an example of the recognized data.

BIRTHDATE: "01/01/1980"
BIRTHDATE_MRZ: "01/01/1980"
DOC_NUMBER: "BAB183428"
DOC_NUMBER_MRZ: "BAB183428"
EXP: "01/01/2013"
EXPEDITOR: "ESP"
EXPEDITOR_MRZ: "ESP"
EXPEDITOR_VIZ: "ESP"
EXP_MRZ: "01/01/2013"
ID_NUMBER: "44282767Q0"
ID_NUMBER_MRZ: "44282767Q0"
MODEL_ID: "IDESP3"
MRZ-1: "IDE5PBAB1834284<44282767Q0<<<<"
MRZ-2: "8001010F1301017ESP<<<<<<<<<<<3"
MRZ-3: "MUESTRA<MUESTRA<<CARMEN<<<<<<<"
NAME: "CARMEN"
NATIONALITY: "ESP"
NATIONALITY_MRZ: "ESP"
SEX: "F"
SEX_MRZ: "F"
SIDE: "2"
SIDES_NUMBER: "2"
SURNAME: "MUESTRA MUESTRA"
TYPE: "IDENTITY"

BIOGEN

With this mode of operation is generated the biometric profile of the user that is in front of the webcam. This profile is stored in the current session of the component and can be used later with the recognition operation mode. A minimum of 5 captures is required to generate the biometric profile.

<script>
    window.initIdCapture = function (Bidcapture) {
        Bidcapture.setMode('BIOGEN');
    };
</script>

BIOREC

With this mode of operation the recognition of the user is activated according to the generated biometric profile. It is necessary that the biometric profile was previously generated with the BIOGEN mode.

<script>
    window.initIdCapture = function (Bidcapture) {
        Bidcapture.setMode('BIOREC');
    };
</script>