Class: PassportCaptureExperience

PassportCaptureExperience()

new PassportCaptureExperience()

Methods

addImageCapturedListener(successCallback, errorCallback, imageCaptureCallback)

A listener that will be called when an passport image was captured. This will only be sent after the experience receives a takePicture message. The experience will wait until the desired stability, levelness, and camera adjustments are met and then capture an image. It would then send the imageID of the captured image to success call back method. Add this event listener before calling the 'takePicture' method.
Parameters:
Name Type Description
successCallback function Default Success Call back function name
errorCallback function Default Error Call back function name
imageCaptureCallback function A JSON object containing the properties of the captured image object. Check the 'Image' object for its properties.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - success string indicating the method has been invoked errorCallback - error in case any error occurs
Example
function imageCaptureCallback(image){
      alert(image.imageid);
}
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var passportCaptureExperience = kfxCordova.kfxUicontrols.createPassportCaptureExperience();
passportCaptureExperience.addImageCapturedListener(successCallback, errorCallback, imageCaptureCallback);

bindCaptureControl(successCallback:, errorCallback:, imageCaptureControlID)

Method to bind the created ImageCapture Control with the PassportCaptureExperience class .
Parameters:
Name Type Description
successCallback: function Default Success call back function name
errorCallback: function Default Error call back function name
imageCaptureControlID String : Pass the ID retrieved for the Image Capture Control If a wrong ID is passed an error is received in the error callback
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - success string indicating the method has been invoked errorCallback - error in case any error occurs
Example
var imageCaptureControl =  kfxCordova.kfxUicontrols.createImageCaptureControl();
var passportCaptureExperience =  kfxCordova.kfxUicontrols.createPassportCaptureExperience();
var imageCaptureControlID = null;
imageCaptureControl.getId(function(captureControlID){
      imageCaptureControlID = captureControlID;
},function(error){
      alert(JSON.stringify(error));
});
passportCaptureExperience.bindCaptureControl(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},imageCaptureControlID);

bindCaptureControlWithOptions(successCallback:, errorCallback:, options)

Method to bind the created ImageCapture Control with the PassportCaptureExperience class and also to set options. This method is a combination of bindCaptureControl API and setOptions API.
Parameters:
Name Type Description
successCallback: function Default Success call back function name
errorCallback: function Default Error call back function name
options Object : A JSON object containing the ID retrieved for the Image Capture Control and the properties to be set to the PassportCaptureExperience. If a wrong ID is passed an error is received in the error callback
Properties
Name Type Attributes Description
ImageCaptureControlID String <optional>
: Pass the ID retrieved for the Image Capture Control. If a wrong ID is passed an error is received in the error callback
CaptureExperienceOptions Object <optional>
: a 'passportCaptureExperienceOptions' variable containing the properties to be set to the PassportCaptureExperience
See:
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - success string indicating the method has been invoked errorCallback - error in case any error occurs
Example
var imageCaptureControl =  kfxCordova.kfxUicontrols.createImageCaptureControl();
var passportCaptureExperience =  kfxCordova.kfxUicontrols.createPassportCaptureExperience();
var imageCaptureControlID = null;
var passportCaptureExperienceOptions = null;
passportCaptureExperience.getOptions(function(success){passportCaptureExperienceOptions = success},function(error){alert(JSON.stringify(error));});
imageCaptureControl.getId(function(captureControlID){
      imageCaptureControlID = captureControlID;
},function(error){
      alert(JSON.stringify(error));
});
passportCaptureExperience.bindCaptureControlWithOptions(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},{"ImageCaptureControlID":imageCaptureControlId,"CaptureExperienceOptions":passportCaptureExperienceOptions});

destroy(successCallback, errorCallback)

Method to clear native Passport CaptureExperience object and its properties.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - success string indicating the method has been invoked errorCallback - error in case any error occurs
Example
function errorCallback(error){
      alert(JSON.stringify(error));
}
function successCallback(options){
      alert(JSON.stringify(options));
}

var imageCaptureControl =  kfxCordova.kfxUicontrols.createImageCaptureControl();
var passportCaptureExperience =  kfxCordova.kfxUicontrols.createPassportCaptureExperience();
var imageCaptureControlID = null;

imageCaptureControl.getId(function(captureControlID){
      imageCaptureControlID = captureControlID;
},function(error){
      alert(JSON.stringify(error));
});

passportCaptureExperience.bindCaptureControl(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},imageCaptureControlID);
passportCaptureExperience.takePictureContinually(successCallback,errorCallback);
passportCaptureExperience.destroy(successCallback,errorCallback);

getOptions(successCallback, errorCallback)

Method to get the properties of the native PassportCaptureExperience class.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - success string indicating the method has been invoked errorCallback - error in case any error occurs
Example
function errorCallback(error){
      alert(JSON.stringify(error));
}
function successCallback(options){
      alert(JSON.stringify(options));
      // Optionally you can get the properties and map to the application UI to show the user
}

var imageCaptureControl =  kfxCordova.kfxUicontrols.createImageCaptureControl();
var passportCaptureExperience =  kfxCordova.kfxUicontrols.createPassportCaptureExperience();
var imageCaptureControlID = null;


imageCaptureControl.getId(function(captureControlID){
      imageCaptureControlID = captureControlID;
},function(error){
      alert(JSON.stringify(error));
});

passportCaptureExperience.bindCaptureControl(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},imageCaptureControlID);
passportCaptureExperience.getOptions(successCallback,errorCallback);

getPassportCaptureOptions()

Method returning the 'PassportCaptureExperience' class properties that can be set by the user. Use this object as an input parameter to set the properties of the PassportCaptureExperience class. The parameters are grouped, and has default values.
Example
var passportCaptureExperience =  kfxCordova.kfxUicontrols.createPassportCaptureExperience();
var passportCaptureOptions = passportCaptureExperience.getPassportCaptureOptions();
passportCaptureOptions should be like below {
   LookAndFeel: {
        enableAnimationTutor: false,
        outerViewFinderColor : "#B2000000",
        vibrationEnabled : true,
        tutorialSampleImagePath : '',
        guidanceFrameColor : "#00FF00"
   },
   CaptureCriteria: {
        stabilityThresholdEnabled: true,
        stabilityThreshold: 95,
        focusEnabled: true,
        rollThresholdEnabled: true,
        rollThreshold: 15,
        pitchThreshold: 15,
        pitchThresholdEnabled: true,
        PassportDetectionSettings:{
           DetectionSettings:{
              centerPoint:{
                 x: null,
                 y: null
              },
              aspectRatio: 1.45,
              padding: 5.0,
              minFillFraction: 0.65,
              maxFillFraction: 1.3,
              maxSkewAngle: 10.0,
              toleranceFraction: 0.15
           }
        }
   },
   UserInstructionMessage: {
        backgroundColor: "#00000000",
        textColor: "#FFFFFFFF",
        message: "Fill viewable area with passport",
        visible: true,
        orientation: "LANDSCAPE",
        fontAndroid: {
          textSize : -1
        },
        fontiOS:{
          fontSize : -1,
          fontName : "HelveticaNeue"
        },
        position :{
           x : -1,
           y : -1
        },
        size:{
           width: -1,
           height: -1
        }
   },
   HoldSteadyMessage: {
        backgroundColor: "#B2000000",
        textColor: "#FFFF0000",
        message: "Hold Steady",
        visible: true,
        orientation: "LANDSCAPE",
        fontAndroid: {
          textSize : -1
        },
        fontiOS:{
          fontSize : -1,
          fontName : "HelveticaNeue"
        },
        position :{
           x : -1,
           y : -1
        },
        size:{
           width: -1,
           height: -1
        }
   },
   CapturedMessage: {
        backgroundColor: "#B2000000",
        textColor: "#00F900",
        message: "Done!",
        visible: true,
        orientation: "LANDSCAPE",
        fontAndroid: {
          textSize : -1
        },
        fontiOS:{
          fontSize : -1,
          fontName : "HelveticaNeue"
        },
        position :{
           x : -1,
           y : -1
        },
        size:{
           width: -1,
           height: -1
        }
   },
   CenterMessage: {
        backgroundColor: "#B2000000",
        textColor: "#FFFFFFFF",
        message: "Center Passport",
        visible: true,
        orientation: "LANDSCAPE",
        fontAndroid: {
          textSize : -1
        },
        fontiOS:{
          fontSize : -1,
          fontName : "HelveticaNeue"
        },
        position :{
           x : -1,
           y : -1
        },
        size:{
           width: -1,
           height: -1
        }
   },
   ZoomInMessage: {
        backgroundColor: "#B2000000",
        textColor: "#FFFFFFFF",
        message: "Move Closer",
        visible: true,
        orientation: "LANDSCAPE",
        fontAndroid: {
          textSize : -1
        },
        fontiOS:{
          fontSize : -1,
          fontName : "HelveticaNeue"
        },
        position :{
           x : -1,
           y : -1
        },
        size:{
           width: -1,
           height: -1
        }
   },
   ZoomOutMessage: {
        backgroundColor: "#B2000000",
        textColor: "#FFFFFFFF",
        message: "Move Back",
        visible: true,
       orientation: "LANDSCAPE",
       fontAndroid: {
          textSize : -1
        },
        fontiOS:{
          fontSize : -1,
          fontName : "HelveticaNeue"
        },
        position :{
           x : -1,
           y : -1
        },
        size:{
           width: -1,
           height: -1
        }
   },
   RotateMessage: {
           backgroundColor: "#B2000000",
           textColor: "#FFFFFFFF",
           message: "Rotate Device",
           visible: true,
           orientation: "LANDSCAPE",
           fontAndroid: {
             textSize : -1
          },
          fontiOS:{
             fontSize : -1,
             fontName : "HelveticaNeue"
           },
          position :{
              x : -1,
              y : -1
           },
           size:{
              width: -1,
              height: -1
           }
       },
   HoldParallelMessage: {
           backgroundColor: "#B2000000",
           textColor: "#FFFFFFFF",
           message: "Hold Device Level",
           visible: true,
           orientation: "LANDSCAPE",
           fontAndroid: {
             textSize : -1
          },
          fontiOS:{
             fontSize : -1,
             fontName : "HelveticaNeue"
           },
           position :{
              x : -1,
              y : -1
           },
           size:{
              width: -1,
              height: -1
           }
       },
   TutorialDismissMessage: {
               backgroundColor: "#B2000000",
               textColor: "#FFFFFFFF",
               message: "Tap to dismiss",
               visible: true,
               orientation: "LANDSCAPE",
               fontAndroid: {
                 textSize : -1
              },
              fontiOS:{
                 fontSize : -1,
                 fontName : "HelveticaNeue"
               },
               position :{
                  x : -1,
                  y : -1
               },
               size:{
                  width: -1,
                  height: -1
               }
           }

   };

removeImageCapturedListener(successCallback, errorCallback)

The method would remove the listener to the delegate call back of the takePicture method.
Parameters:
Name Type Description
successCallback function Default Success Call back function name
errorCallback function Default Error Call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - success string indicating the method has been invoked errorCallback - error in case any error occurs
Example
function successCallback(response){
  alert(JSON.stringify(response));
}
function errorCallback(error){
  alert(JSON.stringify(error));
}
var passportCaptureExperience = kfxCordova.kfxUicontrols.createPassportCaptureExperience();
//after taking picture
passportCaptureExperience.removeImageCapturedListener(successCallback,errorCallback);

setOptions(successCallback, errorCallback, options)

Method to set the properties of the native PassportCaptureExperience class.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
options Object a 'passportCaptureExperienceOptions' variable containing the properties to be set to the PassportCaptureExperience
Properties
Name Type Attributes Description
PassportDetectionSettings Object <optional>
passport detection settings
Properties
Name Type Attributes Description
DetectionSettings Object <optional>
detection settings
Properties
Name Type Attributes Default Description
centerPoint Object <optional>
center point of the document. Should just be a point with in the bounds of the image height and width.
Properties
Name Type Attributes Description
x Number <optional>
x value of the center. Should just be with in the bounds of the image of the target frame.
y Number <optional>
y value of the center. Should just be with in the bounds of the image of the target frame.
aspectRatio Number <optional>
0 aspect ratio of the document. Aspect ratio between 0 and 1 or negative is not recommended. It can result in erroneous detection of target frame. The aspect ratio is presented in the format of longEdge/shortEdge, and is used to construct the largest target frame. If the targetFrameAspectRatio is set to 0, then it will be automatically reset to an image aspect ratio.
padding Number <optional>
5 padding percent value. Values will be clamped to the range [0-50]. The default value is 5.
minFillFraction Number <optional>
0.65 minimum fill fraction value. Setting a negative number is ignored.
maxFillFraction Number <optional>
1.3 maximum fill fraction value. Setting a negative number is ignored.
maxSkewAngle Number <optional>
10 maximum skew angle value. The default value is 10, specified in degrees. Setting a negative number is ignored.
toleranceFraction Number <optional>
0.15 tolerance fraction value. Setting a negative number is ignored.
See:
Example
function successCallback(response){
  alert(JSON.stringify(response));
}
function errorCallback(error){
  alert(JSON.stringify(error));
}
var imageCaptureControl =  kfxCordova.kfxUicontrols.createImageCaptureControl();
var passportCaptureExperience =  kfxCordova.kfxUicontrols.createPassportCaptureExperience();
var imageCaptureControlID = null;
imageCaptureControl.getId(function(captureControlID){
      imageCaptureControlID = captureControlID;
},function(error){
      alert(JSON.stringify(error));
});
passportCaptureExperience.bindCaptureControl(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},imageCaptureControlID);
//get the options
passportCaptureExperience.getOptions(function(success){passportCaptureExperienceOptions = success},myerrorCB);
//specify the values for the Passport Capture Experience
passportCaptureExperienceOptions.CaptureCriteria.focusEnabled = false;
//specify the path for tutorial sample image, which is relative to www folder.
passportCaptureExperienceOptions.LookAndFeel.tutorialSampleImagePath = 'www/images/custom_tutorialimage.png';
//set the options to capture view
passportCaptureExperience.setOptions(successCallback,errorCallback,passportCaptureExperienceOptions)

stopCapture(successCallback, errorCallback)

Calling this method will stop the image capture process. In case of continuous capture also no further images would be captured after this API is called even if the device declination is changed
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - success string indicating the method has been invoked errorCallback - error in case any error occurs
Example
function successCallback(response){
  alert(JSON.stringify(response));
}
function errorCallback(error){
  alert(JSON.stringify(error));
}
var imageCaptureControl =  kfxCordova.kfxUicontrols.createImageCaptureControl();
var passportCaptureExperience =  kfxCordova.kfxUicontrols.createPassportCaptureExperience();
var imageCaptureControlID = null;
imageCaptureControl.getId(function(captureControlID){
      imageCaptureControlID = captureControlID;
},function(error){
      alert(JSON.stringify(error));
});
passportCaptureExperience.bindCaptureControl(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},imageCaptureControlID);
passportCaptureExperience.takePictureContinually(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));});
passportCaptureExperience.stopCapture(successCallback,errorCallback);

takePicture(successCB:, errorCB:)

Calling this method will start the process of monitoring the various constraints passed to determine when a level, focused, and non-blurry shot of the passport can be taken. The event listener "addImageCapturedListener" will receive the delegate call back message and will have the corresponding capture image details.
Parameters:
Name Type Description
successCB: Default Success call back function name
errorCB: Default Error call back function name
Returns:
The return value is captured in the 'successCB' for a successful operation, and might return in 'errorCB' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCB : success string indicating the method has been invoked errorCB : error in case any error occurs
Example
var imageCaptureControl =  kfxCordova.kfxUicontrols.createImageCaptureControl();
var passportCaptureExperience =  kfxCordova.kfxUicontrols.createPassportCaptureExperience();
var imageCaptureControlID = null;
imageCaptureControl.getId(function(captureControlID){
      imageCaptureControlID = captureControlID;
},function(error){
      alert(JSON.stringify(error));
});
passportCaptureExperience.bindCaptureControl(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},imageCaptureControlID);
passportCaptureExperience.takePicture(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));});

takePictureContinually(successCallback, errorCallback)

Calling this method will start the process of monitoring the various constraints passed to determine when a level, focused, and non-blurry shot of the Passport can be taken. The event listener "addImageCapturedListener" will receive the delegate call back message and will have the corresponding capture image details. This method will take pictures continuously. The pitch or roll of the device has to be changed from the set device declination values between each capture.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - success string indicating the method has been invoked errorCallback - error in case any error occurs
Example
var imageCaptureControl =  kfxCordova.kfxUicontrols.createImageCaptureControl();
var passportCaptureExperience =  kfxCordova.kfxUicontrols.createPassportCaptureExperience();
var imageCaptureControlID = null;
imageCaptureControl.getId(function(captureControlID){
      imageCaptureControlID = captureControlID;
},function(error){
      alert(JSON.stringify(error));
});
passportCaptureExperience.bindCaptureControl(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},imageCaptureControlID);
passportCaptureExperience.takePictureContinually(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));});