new ImageProcessor()
An instance of this class contains methods to process images. It holds the profile that specifies the kind of
image processing to perform based on a selected image processing profile. Use the methods on this object to do standard
image processing, perform a quick quality analysis and to find a signature in the image for a particular area.
Methods
addAnalysisCompleteListener(successCallback, errorCallback, analysisCompleteCallback)
This method would receive the Image Analysis complete at the ImageProcessor and the new corresponding details
are captured in success call back.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success Call back function name |
errorCallback |
function | Default Error Call back function name |
analysisCompleteCallback |
function | a var to hold any value returned from the analysis complete listener of the processor class |
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.
analysisCompleteCallback - a var to hold 'QuickAnalysisFeedback' returned from the analysis completed listener of the processor class
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
function analysisCompleteCallback(){
alert('analysis complete callback');
}
var imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
ImageProcessor.prototype.addAnalysisCompleteListener(successCallback,errorCallback,analysisCompleteCallback);
addAnalysisProgressListener(successCallback, errorCallback, analysisProgressCallback)
This method would receive the Image Analysis progress at the ImageProcessor and the new corresponding details
are captured in success call back.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success Call back function name |
errorCallback |
function | Default Error Call back function name |
analysisProgressCallback |
function | a var to hold the current analysis progress listener call from processor |
- 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 with ErrorMsg & ErrorDesc' giving the description of the error.
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.
analysisProgressCallback - return the current analysis progress for a 'doQuickAnalysis' method
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
function analysisProgressCallback(){
alert('analysis progress callback');
}
var imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.addAnalysisProgressListener(successCallback,errorCallback,analysisProgressCallback);
addImageOutEventListener(successCallback, errorCallback, imageOutCallback)
This method would receive the on image processed at the ImageProcessor and the new corresponding details
are captured in success call back.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success Call back function name |
errorCallback |
function | Default Error Call back function name |
imageOutCallback |
function | the processed image properties are returned in this variable in the form a JSOn object |
- 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 with ErrorMsg & ErrorDesc' giving the description of the error.
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.
imageOutCallback - will have the processed image properties returned in the form a JSON object
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
function imageOutCallback(){
alert('image out callback');
}
var imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.addImageOutEventListener(successCallback,errorCallback,imageOutCallback);
addProcessProgressListener(successCallback, errorCallback, processCallback)
This method would receive the Image process progress at the ImageProcessor and the new corresponding details
are captured in success call back.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success Call back function name |
errorCallback |
function | Default Error Call back function name |
processCallback |
function | a variable to hold any value returned from the progress change listener of the processor class |
- 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 with ErrorMsg & ErrorDesc' giving the description of the error. 'processCallback' a variable to hold any value returned from the progress change listener of the processor class
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.
processCallback - will have the processed 'ProgressPercent', 'imageID' returned in the form a JSON object
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
function processCallback(){
alert('analysis complete callback');
}
var imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.addProcessProgressListener(successCallback,errorCallback,processCallback);
cancelImageProcess(successCallback, errorCallback)
Use the cancelProcessing method to cancel an image processing operation that is underway. In, this way, the app can respond to low-memory events or, for any reason, the app user manually stops processing while the image is being processed in background. To do this, asynchronously call a cancel method in the Image Processor engine. Note that there may be a delay between cancelling and the imageOut delegate because the image processor will only cancel the balance of processing tasks on functional boundaries. The image out event will indicate that the processing was cancelled if the image processing operation was incomplete.
The library ignores the cancelProcessing call if the operation has already completed or hasn't started yet. If you cancel processing beforehand, the library will not cancel immediately if you then call processImage.
Background image processing and the cancel operation are both asynchronous. Depending on the current percentage last reported by the progress delegate, the image processing operation may be nearly complete. Therefore, the library may not necessarily cancel an operation, and the cancel error status may not occur. If the operation is cancelled, the imageOut delegate will indicate the KMC_EV_USER_ABORT status. In this case, there will be no image object included with the imageOut delegate.
The cancelProcessing method will cancel either a quick analysis or an image processing operation.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success call back function name |
errorCallback |
function | Default Error call back function name |
- See:
-
- For ANDROID, return value is captured in the 'successCallback' function. This method returns KMC_EV_CANCEL_OPERATION_SUCCESS when the image processing cancelled successfully.
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 imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.cancelImageProcess(successCallback, errorCallback);
doQuickAnalysis(successCallback, errorCallback, options)
Use this method to specify the image upon which you want to perform a quick analysis. The image processor will check image quality and determine the page edges of a document in the image.
The doQuickAnalysis method does not use a profile. The library uses an internally generated opString, and ignores the basic settings profile and the image perfection profile set in the image processor object.
License Required: this is a licensed method. You cannot use this method until you have set a valid SDK license. In order to set your license, you need to use the setMobileSDKLicense method on the kfxKUTLicensing object. An example of setting your license can be found in the licensing class.
The method returns KMC_SUCCESS if the process starts without any error. In this case you should expect multiple analysis process progress delegate calls to indicate the progress of the analysis. You should never make any assumptions about completion of the process when you get to 100% completion, because the library performs several post process steps and then calls the analysisComplete delegate. You should always check the status in the analysis complete delegate to know if the process completed without error.
If the call to doQuickAnalysis method does not return KMC_SUCCESS, then the library will not have stored the kfxKEDQuickAnalysisFeedback object, and you will not receive any progress delegate calls nor a analysisComplete delegate call. Therefore, you should always check the return value to make sure you have correctly initialized objects for the process and analysis starts up ok.
Quick analysis always returns a kfxKEDImage in the analysisComplete delegate, and this is a reference to the same input image given to quick analysis with the imageToAnalyze parameter. When Quick Analysis completes without error, it stores a kfxKEDQuickAnalysisFeedback object in the input image for your use. If you request a reference image, by setting the generateRefImage to true, then the library returns a UIImage reference in the kfxKEDQuickAnalysisFeedback object.
Quick Analysis Results are always stored in the kfxKEDQuickAnalysisFeedback object in the input image specified with the imageToAnalyze parameter. Then you can decide what to do with the results. You should examine the various settings in the kfxKEDQuickAnalysisFeedback object, to see if the image is blurry, over saturated, under saturated or not. The library also sets the bounding tetragon corners and side equations for the page boundaries in the feedback object and the metadata. Then if the image looks good, you can also display the reference UIImage * if you requested one. You could display this image for user confirmation, and then a new picture could be taken if the user decides he doesn't like the results, or the green bordered image of the page seems incorrect.
Otherwise, if your user accepts the image, you could then process the image using a standard processImage call. When you do so, if you want to crop to the page detection referenced by the quick analysis process, you should use a basic settings profile, and set the doCrop setting to KED_CROP_WITH_QUICK_ANALYSIS_RESULTS, and your image processing will complete sooner than if you did normal processing because the library already knows the page boundaries.
Note: The library ignores any supplied profiles and uses internal settings instead. This data is returned in the quick analysis feedback object in the input imageToAnalyze object.
The analysisComplete delegate returns your input image, and everything in it is retained.
When the processing completes normally, the library sets the following image object properties:
imageQuickAnalysisFeedback, set to an object created by the analysis, indicating the results, and a reference image if requested. imageMetaData, to the quick analysis metadata created by the image processor for quick analysis.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
successCallback |
function | Default Success call back function name | ||||||||||||
errorCallback |
function | Default Error call back function name | ||||||||||||
options |
Object | doQuickAnalysis options
Properties
|
- See:
-
- Use - cancelProcessing to cancel an ongoing quick analysis process if necessary.
Returns:
The return value is captured in the 'successCallback' and can have any of the following results.
This method returns KMC_SUCCESS when image processing started without error. Otherwise it may return one of these error codes if processing was not started. No delegates are generated if the method returns an error.
KMC_IP_LICENSE_INVALID if you have not set a valid license yet. KMC_ED_NOIMAGE If you did not include an image in the input image object.
KMC_ED_FILEPATH If the image object is represented by a file, but the file path is missing.
KMC_ED_NONEXISTENT_FILE If the file name in the input object was specified so that the image representation is set to IMAGE_REP_FILE, an then the file used to represent the image is later deleted. The the library returns this error if you try to process it.
KMC_IP_NO_REPRESENTATION If the image representation in the input image object is invalid, and not set to IMAGE_REP_FILE, or IMAGE_REP_BITMAP or BOTH. This indicates that there is no image to process. This is returned even if you set a file path to a non-existent file.
KMC_ED_NO_MEMORY_FOR_METADATA if memory could not be allocated to store image metadata.
KMC_ED_IMAGE_COLOR_SPACE If the library could not create a color space reference, usually a system resource issue.
KMC_ED_IMAGE_CONTEXT, If an image bitmap could not be created, normally caused by a resource issue.
KMC_EV_PROCESS_PAGE_BUSY/KMC_IP_CONTEXT, Another thread is calling the image processor for page process operation. Application can either retry after certain period of time, or cancel the operation
//ANDROID ERROR CODES
NullPointerException ('image' parameter is null).
KmcException (KMC_EV_PROCESS_PAGE_BUSY).
KmcException (KMC_ED_NONEXISTENT_FILE).
KmcRuntimeException (KMC_ED_FILEPATH).
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var options = {
imageID: imageToAnalyze,
generateOutputImage: false
};
var imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.doQuickAnalysis(successCallback,errorCallback, options);
doQuickAnalysisWithSettings(successCallback, errorCallback, options)
Use this method to specify the image upon which you want to perform a quick analysis. The image processor will check image quality and determine the page edges of a document in the image.
The doQuickAnalysis method does not use a profile. The library uses an internally generated opString, and ignores the basic settings profile and the image perfection profile set in the image processor object.
License Required: this is a licensed method. You cannot use this method until you have set a valid SDK license. In order to set your license, you need to use the setMobileSDKLicense method on the kfxKUTLicensing object. An example of setting your license can be found in the licensing class.
The method returns KMC_SUCCESS if the process starts without any error. In this case you should expect multiple analysis process progress delegate calls to indicate the progress of the analysis. You should never make any assumptions about completion of the process when you get to 100% completion, because the library performs several post process steps and then calls the analysisComplete delegate. You should always check the status in the analysis complete delegate to know if the process completed without error.
If the call to doQuickAnalysis method does not return KMC_SUCCESS, then the library will not have stored the kfxKEDQuickAnalysisFeedback object, and you will not receive any progress delegate calls nor a analysisComplete delegate call. Therefore, you should always check the return value to make sure you have correctly initialized objects for the process and analysis starts up ok.
Quick analysis always returns a kfxKEDImage in the analysisComplete delegate, and this is a reference to the same input image given to quick analysis with the imageToAnalyze parameter. When Quick Analysis completes without error, it stores a kfxKEDQuickAnalysisFeedback object in the input image for your use. If you request a reference image, by setting the generateRefImage to true, then the library returns a UIImage reference in the kfxKEDQuickAnalysisFeedback object.
Quick Analysis Results are always stored in the kfxKEDQuickAnalysisFeedback object in the input image specified with the imageToAnalyze parameter. Then you can decide what to do with the results. You should examine the various settings in the kfxKEDQuickAnalysisFeedback object, to see if the image is blurry, over saturated, under saturated or not. The library also sets the bounding tetragon corners and side equations for the page boundaries in the feedback object and the metadata. Then if the image looks good, you can also display the reference UIImage * if you requested one. You could display this image for user confirmation, and then a new picture could be taken if the user decides he doesn't like the results, or the green bordered image of the page seems incorrect.
Otherwise, if your user accepts the image, you could then process the image using a standard processImage call. When you do so, if you want to crop to the page detection referenced by the quick analysis process, you should use a basic settings profile, and set the doCrop setting to KED_CROP_WITH_QUICK_ANALYSIS_RESULTS, and your image processing will complete sooner than if you did normal processing because the library already knows the page boundaries.
Note: The library ignores any supplied profiles and uses internal settings instead. This data is returned in the quick analysis feedback object in the input imageToAnalyze object.
The analysisComplete delegate returns your input image, and everything in it is retained.
When the processing completes normally, the library sets the following image object properties:
imageQuickAnalysisFeedback, set to an object created by the analysis, indicating the results, and a reference image if requested. imageMetaData, to the quick analysis metadata created by the image processor for quick analysis.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
successCallback |
function | Default Success call back function name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
errorCallback |
function | Default Error call back function name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object | doQuickAnalysis with settings options
Properties
|
- See:
-
- Use - cancelProcessing to cancel an ongoing quick analysis process if necessary.
Returns:
The return value is captured in the 'successCallback' and can have any of the following results.
This method returns KMC_SUCCESS when image processing started without error. Otherwise it may return one of these error codes if processing was not started. No delegates are generated if the method returns an error.
KMC_IP_LICENSE_INVALID if you have not set a valid license yet. KMC_ED_NOIMAGE If you did not include an image in the input image object.
KMC_ED_FILEPATH If the image object is represented by a file, but the file path is missing.
KMC_ED_NONEXISTENT_FILE If the file name in the input object was specified so that the image representation is set to IMAGE_REP_FILE, an then the file used to represent the image is later deleted. The the library returns this error if you try to process it.
KMC_IP_NO_REPRESENTATION If the image representation in the input image object is invalid, and not set to IMAGE_REP_FILE, or IMAGE_REP_BITMAP or BOTH. This indicates that there is no image to process. This is returned even if you set a file path to a non-existent file.
KMC_ED_NO_MEMORY_FOR_METADATA if memory could not be allocated to store image metadata.
KMC_ED_IMAGE_COLOR_SPACE If the library could not create a color space reference, usually a system resource issue.
KMC_ED_IMAGE_CONTEXT, If an image bitmap could not be created, normally caused by a resource issue.
KMC_EV_PROCESS_PAGE_BUSY/KMC_IP_CONTEXT, Another thread is calling the image processor for page process operation. Application can either retry after certain period of time, or cancel the operation
//ANDROID ERROR CODES
NullPointerException ('image' parameter is null).
KmcException (KMC_EV_PROCESS_PAGE_BUSY).
KmcException (KMC_ED_NONEXISTENT_FILE).
KmcRuntimeException (KMC_ED_FILEPATH).
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var quickAnalysisSettings={
enableBlurDetection:true,
blurThreshold:0,
blurCountPercentThreshold:0,
enableSaturationDetection:true,
enableGlareDetection:true,
glareDetectionIntensityFraction:0.03,
glareDetectionIntensityThreshold:230,
glareDetectionMinimumGlareAreaFraction:0.01,
glareDetectionNumberOfTiles:100,
glareDetectedThreshold:0.02
};
var options = {
imageID: imageToAnalyze,
generateOutputImage: false,
settings:quickAnalysisSettings
};
var imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.doQuickAnalysisWithSettings(successCallback,errorCallback, options);
getImageProcessingOptions()
Method returning the 'ImageProcessor' class properties that can be set by the user. Use this object as an input
parameter to set the properties of the ImageProcessor class. The parameters are grouped, and has the below mentioned
default values.
Example
var imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
var imageProcessorOptions = imageProcessor.getImageProcessingOptions();
imageProcessorOptions should be like below {
ProcessedImage:{
representation:'IMAGE_REP_BITMAP',
mimeType:'MIMETYPE_JPEG',
jpegQuality:50
},
BasicSettingsProfile:{
rotateType:'ROTATE_NONE',
cropType:'CROP_AUTO',
doDeskew:true,
inputDocShortEdge:0.0,
inputDocLongEdge:0.0,
BoundingTetragon:{
TopLeft:{
x:0,
y:0
},
TopRight:{
x:0,
y:0
},
BottomLeft:{
x:0,
y:0
},
BottomRight:{
x:0,
y:0
}
},
outputDPI:0,
outputBitDepth:'BITONAL'
},
ImagePerfectionProfile:{
name:null,
ipOperations:null,
ipOperationsFilePath:null
},
ImageProcessorConfiguration:{
rotateType:'ROTATE_NONE',
outputColorDepth: 'COLOR',
cropType: 'CROP_NONE',
targetFrameCropType: 'TARGET_FRAME_CROP_OFF',
deskewType: 'DESKEW_NONE',
DocumentDimensions:{
shortEdge: 0.0,
longEdge: 0.0
},
outputDPI:0,
advancedConfiguration: null,
ippString: null
}
};
getImageProcessorOptions(successCallback, errorCallback)
Method to get the properties of the native ImageProcessor 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 ImageProcessor Options. JSONObject structure can also be known from getImageProcessingOptions() 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 imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.getImageProcessorOptions(successCallback,errorCallback);
getProcessedImageFilePath(successCallback, errorCallback)
Use this method to retrieve the current file path associated with this object. In some cases, the file name may not have been set if the specifyProcessedImageFilePath method returned an error.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success call back function name. Return values of the exec call is captured here. |
errorCallback |
function | Default Error call back function name, and any failure in executing the 'exec' call are captured here.s |
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 with file path specified for 'specifyProcessedImageFilePath' method
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 imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.getProcessedImageFilePath(successCallback,errorCallback);
getQuickAnalysisOptions()
Method returning the QuickAnalysis properties that can be set by the user. Use this object as an input parameter to set
options on QuickAnalysis
Example
var imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
var doQuickAnalysisOptions = imageProcessor.getQuickAnalysisOptions();
doQuickAnalysisOptions should be like below {
imageID:"",
generateOutputImage:true
};
processImage(successCallback, errorCallback, imageID)
Use this method when you want to perform standard image processing on the image supplied with the method. The library
processes the image using the processing options contained in the profile you specified. You can specify either a basic
settings profile or an image perfection profile. If the input image representation is file based, and a bitmap is not supplied,
the library will load and process the image from the file in the image object. If the image is represented by a bitmap,
then the library uses that image, even if the image representation indicates both (bitmap and file).
License Required: this is a licensed method. You cannot use this method until you have set a valid SDK license. In order to set your license, you need to use the setMobileSDKLicense method on the kfxKUTLicensing object. You must obtain a valid license from Kofax in order to use licensed methods. An example of setting your license can be found in the licensing class.
This method generates a brand new kfxKEDImage object, if the image processing completes without error. The library notifies you by calling the imageOut delegate. The output image object does not retain much from the input image.
When the processing completes normally, the library sets the following output image object properties:
imageMimeType, to the MIMETYPE_UNKNOWN setting.
imageBitMap, to the new processed bitmap.
imageRepresentation, to IMAGE_REP_BITMAP, because the bitmap is stored.
imageSourceID, to the imageID of the input image.
imageMetaData, to the metadata created by the image processor.
imagePerfectionProfileUsed or basicSettingsProfileUsed, to the one that was used to produce the output image.
imageGPSLat, to the preserved latitude of the source input file.
imageGPSLon, to the preserved longitude of the source input file.
imageFileOutputColor, to the new color definition of the output image generated.
imageHeight, to the height of the new output image.
imageWidth, to the width of the new output image.
All other image object properties are set to the default.
The output image jpegQuality specifies the JPEG quality for an output image file created by image processing. This is used only when both the following are true:
mimeType is set to MIMETYPE_JPEG, and
representation is set to IMAGE_REP_FILE or IMAGE_REP_BOTH.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success call back function name |
errorCallback |
function | Default Error call back function name |
imageID |
String | the actual input image object that you want to process. An image id in the ImageArray is to be passes as argument |
- See:
-
- Use - cancelProcessing to cancel an image processing operation if necessary.
Returns:
The return value is captured in the 'successCallback' function. This method returns KMC_SUCCESS when the image processing was started up successfully.
Several error codes are returned for this method when the image processing request could not be started, due to such things as memory limitations. In these cases, the method
generates no final completion notification by calling your imageOut delegate. But, if the library returns KMC_SUCCESS, then image processing has started successfully.
Your imageOut delegate is called after the image processing completes, in which case a processing error may be indicated in the delegate. So you should always check this
return value to detect if you should expect progress delegate calls or completion delegate calls. One of these error codes may be returned immediately, in which case the
background processing is not started.
The possible error codes are:
KMC_IP_LICENSE_INVALID if you have not set a valid license yet.
KMC_ED_NO_MEMORY_FOR_METADATA if memory could not be allocated to store image metadata.
KMC_ED_NOIMAGE if you did not include an image in the input image object.
KMC_IP_NO_PROFILE if you forgot to include a profile, either a basic settings or perfection profile.
KMC_ED_FILEPATH if the image object is represented by a file, but the file path is missing.
KMC_ED_NONEXISTENT_FILE If the file name in the input object was set to the name of a non-existent file, and you try to process it.
KMC_IP_NO_REPRESENTATION if the image representation in the input image object is invalid.
KMC_ED_IMAGE_COLOR_SPACE if the library could not create a color space reference, usually a system resource issue.
KMC_ED_IMAGE_CONTEXT if an image bitmap could not be created, normally caused by a resource issue.
//ANDROID ERROR CODES
NullPointerException ('image' parameter is null).
KmcRuntimeException (KMC_IP_NO_PROFILE).
KmcRuntimeException (KMC_ED_NOIMAGE).
KmcRuntimeException (KMC_ED_FILEPATH).
KmcRuntimeException (KMC_ED_MIMETYPE).
KmcRuntimeException (KMC_ED_IMAGE_PERFECTION_PROFILE_EMPTY).
KmcException (KMC_ED_NONEXISTENT_FILE).
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.processImage(successCallback,errorCallback, 'imageid');
removeAnalysisCompleteListener(successCallback, errorCallback)
The method would remove the listener and would not receive the Analysis complete events. After removing the listener,
there will not be any call backs from native .
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 imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.removeAnalysisCompleteListener(successCallback,errorCallback);
removeAnalysisProgressListener(successCallback, errorCallback)
The method would remove the listener and would not receive the Analysis progress events. After removing the listener,
there will not be any call backs from native .
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 imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.removeAnalysisProgressListener(successCallback,errorCallback);
removeImageOutEventListener(successCallback, errorCallback)
The method would remove the listener and would not receive the processed image events. After removing the listener,
there will not be any call backs from native .
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.
removeProcessProgressListener(successCallback, errorCallback)
The method would remove the listener and would not receive the Processed image progress events. After removing the listener,
there will not be any call backs from native .
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 imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.removeProcessProgressListener(successCallback,errorCallback);
setImageProcessorOptions(successCallback, errorCallback, imageProcessorOptions)
Method to set the properties of the native ImageProcessor class.
The output image jpegQuality specifies the JPEG quality for an output image file created by image processing. This is used only when both the following are true:
mimeType is set to MIMETYPE_JPEG, and
representation is set to IMAGE_REP_FILE or IMAGE_REP_BOTH.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
successCallback |
function | Default Success call back function name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
errorCallback |
function | Default Error call back function name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
imageProcessorOptions |
Object | a 'imageProcessorOptions' object containing the image processing properties
Properties
|
- 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 ErrorMsg & ErrorDesc' giving the description of the error. you can understand what are the image processor options by go through this method ImageProcessor#getImageProcessingOptions
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 imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
var imageProcessorOptions = imageProcessor.getImageProcessingOptions();
imageProcessor.setImageProcessorOptions(successCallback,errorCallback,imageProcessorOptions)
specifyProcessedImageFilePath(successCallback, errorCallback, filepath)
Use this method to specify the fully qualified path to a file name that you want to contain the output processed image. Usually this file should not already exist. You should always check for returned error codes because this specifyProcessedImageFilePath method returns errors for certain cases. When this method returns an error, the library will not save the file path. The valid file path extensions are: jpg, jpeg, tif, tiff, png and their upper-case equivalents.
If the file name extension is valid, then the library sets up the imageMimetype setting for you.
This value is only used when the processedImageRepresentation is set to IMAGE_REP_FILE or IMAGE_REP_BOTH.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success call back function name |
errorCallback |
function | Default Error call back function name |
filepath |
String | filepath where you want to write an image. The filepath needs to include imageName with extension(ex:imageName.png). In iOS, it is not required to pass the documents directory path because internally MobileSDK is getting the documents directory path and appending the file path which is coming from the user. In Android, if we pass imageName with extension then the image will write to phone internal storage. If we pass SD card full path (ex:/storage/emulated/0/imageName.png) then the image will write to SD card. |
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 KMC_ED_OBJECT_REP_BITMAP_MISMATCH, when you try to set a file name for an existing file, when there is already a bitmap set for the object.
KMC_ED_FILE_EXTENSION, when you try to set a file name with an illegal file extension, KmcRuntimeException & Exception.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var imageProcessor = kfxCordova.kfxEngine.createImageProcessor();
imageProcessor.specifyProcessedImageFilePath(successCallback, errorCallback,'imageName.png')