new PassportCaptureExperience()
Methods
addImageAboutToCaptureListener(successCallback, errorCallback, imageAboutToCaptureCallback)
A listener that will be called when an image is about to capture. 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.
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 |
imageAboutToCaptureCallback |
function | Call back for event |
- See:
-
- Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. By Default, the error call back would return a JSON object giving ErrMsg & ErrDesc giving the description of the error.
Returns:
The return value is captured in the 'successCallback' function for successful operation.
The 'imageAboutToCaptureCallback' will have return value in this callback
Example
function imageAboutToCaptureCallback(response)
{
alert(JSON.stringify(response));
}
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var passportCaptureExperience = kfxCordova.kfxUicontrols.createPassportCaptureExperience();
passportCaptureExperience.addImageAboutToCaptureListener(successCallback, errorCallback, imageAboutToCaptureCallback);
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
imageObject 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);
addImageJustCapturedListener(successCallback, errorCallback, imageJustCapturedCallback)
A listener that will be called when an image is captured and just before done message is shown. 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
imageObject 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 |
imageJustCapturedCallback |
function | A JSON object containing the properties of the captured image object. Check the 'Image' object for its properties. |
- See:
-
- Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. By Default, the error call back would return a JSON object giving ErrMsg & ErrDesc giving the description of the error.
Returns:
The return value is captured in the 'successCallback' function for successful operation.
The 'imageJustCapturedCallback' will have the JSON object of the captured KfxKEDImage properties. The captured KEDImage is stored in ImageArray.
The image can be retrieved using methods on ImageArray.
Example
function imageJustCapturedCallback(imageObject)
{
alert(JSON.stringify(imageObject));
}
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var passportCaptureExperience = kfxCordova.kfxUicontrols.createPassportCaptureExperience();
passportCaptureExperience.addImageJustCapturedListener(successCallback, errorCallback, imageJustCapturedCallback);
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
|
- See:
-
- Also see PassportCaptureExperience#setOptions for detailed description of parameters what we have to pass.
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,
diagnosticsViewEnabled : false,
guidanceFrameThickness : 8,
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
}
}
};
removeImageAboutToCapturedListener(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.removeImageAboutToCapturedListener(successCallback,errorCallback);
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);
removeImageJustCapturedListener(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.removeImageJustCapturedListener(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
|
- See:
-
- see PassportCaptureExperience#getPassportCaptureOptions for detailed description of parameters what we have to pass.
- Also see PassportCaptureExperience's setOptions API for more.
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));});