new FixedAspectRatioCaptureExperience()
This FixedAspectRatioCaptureExperience class is responsible for handling the corresponding plugin js to interact with the native FixedAspectRatioCaptureExperience
class. To set and get the properties, and to access the instance methods, corresponding JS methods are written under this class which
are used by the end user in application script.
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 fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
fixedAspectRatioCaptureExperience.addImageAboutToCaptureListener(successCallback, errorCallback, imageAboutToCaptureCallback);
addImageCapturedListener(successCallback, errorCallback, imageCaptureCallback)
A listener that will be called when an 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. |
- 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 and will have a zero(0) for successful operation.
The 'imageCaptureCallback' 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 imageCaptureCallback(imageObject)
{
alert(JSON.stringify(imageObject));
}
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
fixedAspectRatioCaptureExperience.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 fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
fixedAspectRatioCaptureExperience.addImageJustCapturedListener(successCallback, errorCallback, imageJustCapturedCallback);
bindCaptureControl(successCallback, errorCallback, imageCaptureControlID)
Method to bind the created ImageCapture Control with the FixedAspectRatioCaptureExperience 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
successCB : KMC_SUCCESS success call back.
errorCB : error message would contain the appropriate error description.Possible error objects are Invalid Capture Control ID, KmcRuntimeException & Exception.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var imageCaptureControl = kfxCordova.kfxUicontrols.createImageCaptureControl();
var imageCaptureControlID = null;
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
imageCaptureControl.getId(function(captureControlID){
imageCaptureControlID = captureControlID;
},function(error){
alert(JSON.stringify(error));
});
fixedAspectRatioCaptureExperience.bindCaptureControl(successCallback,errorCallback,imageCaptureControlID);
bindCaptureControlWithOptions(successCallback, errorCallback, options)
Method to bind the created ImageCapture Control with the FixedAspectRatioCaptureExperience 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 FixedAspectRatioCaptureExperience. If a wrong ID is passed an error is received in the error callback
Properties
|
- See:
-
- Also see FixedAspectRatioCaptureExperience#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
successCB : KMC_SUCCESS success call back.
errorCB : error message would contain the appropriate error description.Possible error objects are Invalid Capture Control ID, KmcRuntimeException & Exception.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var imageCaptureControl = kfxCordova.kfxUicontrols.createImageCaptureControl();
var imageCaptureControlID = null;
var fixedAspectRatioCaptureExperienceOptions = null;
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
fixedAspectRatioCaptureExperience.getOptions(function(success){fixedAspectRatioCaptureExperienceOptions = success},function(error){alert(JSON.stringify(error));});
imageCaptureControl.getId(function(captureControlID){
imageCaptureControlID = captureControlID;
},function(error){
alert(JSON.stringify(error));
});
fixedAspectRatioCaptureExperience.bindCaptureControlWithOptions(successCallback,errorCallback,{"ImageCaptureControlID":imageCaptureControlId,"CaptureExperienceOptions":fixedAspectRatioCaptureExperienceOptions});
destroy(successCallback, errorCallback)
Method to clear FixedAspectRatioCaptureExperience memory.
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 imageCaptureControlID = null;
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
imageCaptureControl.getId(function(captureControlID){
imageCaptureControlID = captureControlID;
},function(error){
alert(JSON.stringify(error));
});
fixedAspectRatioCaptureExperience.bindCaptureControl(successCallback,errorCallback,imageCaptureControlID);
fixedAspectRatioCaptureExperience.takePictureContinually(successCallback,errorCallback);
fixedAspectRatioCaptureExperience.destroy(successCallback,errorCallback);
getFixedAspectRatioCaptureOptions()
Method returning the 'FixedASpectRatioCaptureExperience' class properties that can be set by the user. Use this object as an input
parameter to set the properties of the FixedAspectRatioCaptureExperience class. The parameters are grouped, and has the below mentioned
default values.
Example
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
var fixedAspectRatioCaptureOptions = fixedAspectRatioCaptureExperience.getFixedAspectRatioCaptureOptions();
fixedAspectRatioCaptureOptions should be like below {
LookAndFeel: {
enableAnimationTutor: false,
outerViewFinderColor : "#B2000000",
vibrationEnabled : true,
diagnosticsViewEnabled : false,
guidanceFrameThickness : 8,
tutorialSampleImagePath : '',
guidanceFrameColor : "#00FF00",
guidanceFrameThickness: 8
},
CaptureCriteria: {
stabilityThresholdEnabled: true,
stabilityThreshold: 95,
focusEnabled: true,
rollThresholdEnabled: false,
rollThreshold: 15,
pitchThreshold: 15,
pitchThresholdEnabled: false,
refoucsBeforeCaptureEnabled: true,
holdSteadyDelay: 1.0,
pageDetectionEnabled: true,
FarDetectionSettings:{
DetectionSettings:{
centerPoint:{
x: null,
y: null
},
aspectRatio: 0.6296296296,
padding: 8.0
}
}
},
UserInstructionMessage: {
backgroundColor: "#00000000",
textColor: "#FFFFFFFF",
message: "Fill viewable area with document",
visible: true,
orientation: "PORTRAIT",
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: "PORTRAIT",
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: "PORTRAIT",
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: "PORTRAIT",
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: "PORTRAIT",
fontAndroid: {
textSize : -1
},
fontiOS:{
fontSize : -1,
fontName : "HelveticaNeue"
},
position :{
x : -1,
y : -1
},
size:{
width: -1,
height: -1
}
}
};
getOptions(successCallback, errorCallback)
Method to get the properties of the native FixedAspectRatioCaptureExperience 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 : JSONObject representing FixedAspectRatioCaptureExperience Options. JSONObject structure can also be known from getFixedAspectRatioCaptureOptions() method.
errorCallback : error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,JSONException & Exception.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var imageCaptureControl = kfxCordova.kfxUicontrols.createImageCaptureControl();
var imageCaptureControlID = null;
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
imageCaptureControl.getId(function(captureControlID){
imageCaptureControlID = captureControlID;
},function(error){
alert(JSON.stringify(error));
});
fixedAspectRatioCaptureExperience.bindCaptureControl(successCallback,errorCallback,imageCaptureControlID);
fixedAspectRatioCaptureExperience.getOptions(successCallback,errorCallback);
removeImageAboutToCaptureListener(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 |
- See:
-
- Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with 'ErrorMs' & 'ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' function for successful operation.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
// after taking picture
fixedAspectRatioCaptureExperience.removeImageAboutToCaptureListener(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 |
- See:
-
- Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with 'ErrorMs' & 'ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' function and will have a zero(0) for successful operation.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
// after taking picture
fixedAspectRatioCaptureExperience.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 |
- See:
-
- Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with 'ErrorMs' & 'ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' function and will have a zero(0) for successful operation.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
// after taking picture
fixedAspectRatioCaptureExperience.removeImageJustCapturedListener(successCallback,errorCallback);
setOptions(successCallback, errorCallback, parameters)
Method to set the properties of the native FixedAspectRatioCaptureExperience class.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
successCallback |
function | Default Success call back function name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
errorCallback |
function | Default Error call back function name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
parameters |
Object | a 'fixedAspectRatioExperienceOptions' variable containing the properties to be set to the FixedAspectRatioCaptureExperience | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options.LookAndFeel |
Object | Look and Feel options
Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options.CaptureCriteria |
Object | capture criteria options
Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options.FarDetectionSettings |
Object |
<optional> |
Fixed Aspect Ratio detection settings
Properties
|
- See:
-
- see FixedAspectRatioCaptureExperience#getFixedAspectRatioCaptureOptions for detailed description of parameters what we have to pass.
- Also see DocumentCaptureExperience's setOptions API for more.
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 - KMC_SUCCESS success call back
errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException & Exception.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var imageCaptureControl = kfxCordova.kfxUicontrols.createImageCaptureControl();
var imageCaptureControlID = null, fixedAspectRatioExperienceOptions = null;
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
imageCaptureControl.getId(function(captureControlID){
imageCaptureControlID = captureControlID;
},function(error){
alert(JSON.stringify(error));
});
fixedAspectRatioCaptureExperience.bindCaptureControl(successCallback,errorCallback,imageCaptureControlID);
//get the options
fixedAspectRatioCaptureExperience.getOptions(function(options){fixedAspectRatioCaptureExperienceOptions = options;},errorCallback);
//specify the path for tutorial sample image, which is relative to www folder.
fixedAspectRatioCaptureExperience.LookAndFeel.tutorialSampleImagePath = 'www/images/custom_tutorialimage.png';
// set the options to capture view
fixedAspectRatioCaptureExperience.setOptions(successCallback,errorCallback,fixedAspectRatioCaptureExperienceOptions)
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 - KMC_SUCCESS success call back.
errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException & Exception.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var imageCaptureControl = kfxCordova.kfxUicontrols.createImageCaptureControl();
var imageCaptureControlID = null;
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
imageCaptureControl.getId(function(captureControlID){
imageCaptureControlID = captureControlID;
},function(error){
alert(JSON.stringify(error));
});
fixedAspectRatioCaptureExperience.bindCaptureControl(successCallback,errorCallback,imageCaptureControlID);
fixedAspectRatioCaptureExperience.stopCapture(successCallback,errorCallback);
takePicture(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 document can be taken. The default level indicator will not be rendered unless the levelIndicator property is set to true.
The event listener "addImageCapturedListener" will receive the delegate call back message and will have the corresponding capture image details.
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 - KMC_SUCCESS success call back.
errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException & Exception
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var imageCaptureControl = kfxCordova.kfxUicontrols.createImageCaptureControl();
var imageCaptureControlID = null;
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
imageCaptureControl.getId(function(captureControlID){
imageCaptureControlID = captureControlID;
},function(error){
alert(JSON.stringify(error));
});
fixedAspectRatioCaptureExperience.bindCaptureControl(successCallback,errorCallback,imageCaptureControlID);
fixedAspectRatioCaptureExperience.takePicture(successCallback,errorCallback);
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 document can be taken. The default level indicator will not be rendered unless the levelIndicator property is set to true.
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 - KMC_SUCCESS success call back.
errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException & Exception.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var imageCaptureControl = kfxCordova.kfxUicontrols.createImageCaptureControl();
var imageCaptureControlID = null;
var fixedAspectRatioCaptureExperience = kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
imageCaptureControl.getId(function(captureControlID){
imageCaptureControlID = captureControlID;
},function(error){
alert(JSON.stringify(error));
});
fixedAspectRatioCaptureExperience.bindCaptureControl(successCallback,errorCallback,imageCaptureControlID);
fixedAspectRatioCaptureExperience.takePictureContinually(successCallback,errorCallback);