Class: QuickExtractor

QuickExtractor()

new QuickExtractor()

An instance of this class contains methods to process images. An extractor that extracts either a barcode or MRZ data and a face image from a static source image. This extractor works with static images, see KFXQuickExtractorAgent for a version that processes preview frames during image capture. Use the methods on this object to do quick extraction to find a face in the image and also fields. Note: For proper face extraction, document on image should be straight oriented.

Methods

addQuickExtractionEventListener(successCallback, errorCallback, extractionResultsCallback)

This method would receive the face image and fields at the QuickExtractor and the new corresponding details are captured in success call back. A listener will be called when an image was captured. The extraction result callback would be containing face image and fields.
Parameters:
Name Type Description
successCallback function Default Success Call back function name
errorCallback function Default Error Call back function name
extractionResultsCallback function the fields and face image properties are returned in this variable in the form a JSOn object. If one of these fields or image are not present, then an empty array/empty string are sent respectively
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. extractionResultsCallback - Extraction results are returned in this variable in the form a JSON object.This json object contains data as mentioned below. -> It would also contain Face Image and fields based on the returned results
Example
dataField object is mentioned as below.
 ex:  var dataField ={
       fieldName:"name",
       fieldValue:"value",
       fieldConfidence:0.0,
       fieldLocation : {
                 x     : 0.0,
                 y     : 0.0,
                 width : 0.0,
                 height: 0.0
               }
     };



var extractionResultsCallback = function(result){
  var dataFields = result.extractionResults.fields;
  var faceImageObject = result.extractionResults.faceImage;
           if(result.hasOwnProperty('extractionError')){
             alert("error:: " + result.extractionError);
             }
           

  console.log("Extraction Result: ");
  for(var i = 0; i < dataFields.length; i++){
     var name = dataFields[i].fieldName;
     var value = dataFields[i].fieldValue;
     var confidence = dataFields[i].fieldConfidence;
     var fieldLocation_x =  dataFields[i].fieldLocation.x;
     var fieldLocation_y =  dataFields[i].fieldLocation.y;
     var fieldLocation_width =  dataFields[i].fieldLocation.width;
     var fieldLocation_height =  dataFields[i].fieldLocation.height;
     console.log("Field Name:"+ name +" Field Value: "+value+" confidence:"+confidence+" fieldLocation_x:"+fieldLocation_x+" fieldLocation_y:"+fieldLocation_y+" fieldLocation_width:"+fieldLocation_width+" fieldLocation_height:"+fieldLocation_height);
  }

  var error = result.extractionError;
}

var QuickExtractor = kfxCordova.kfxEngine.createQuickExtractor();

QuickExtractor.addQuickExtractionEventListener(function(success){
   alert(JSON.stringify(success));
},function(error){
   if(!error.hasOwnProperty('extractionError')){
                   alert("error in addQuickExtractionListener :" + JSON.stringify(error));
   }else{
           if(error.hasOwnProperty('extractionError')){
             alert(" error:: " + error.extractionError);
             }
   }
}, extractionResultsCallback);

destroy(successCallback, errorCallback)

The method would destroy the QuickExtractor and wouldn't receive any callbacks further
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.

getQuickExtractorSettings()

Method returning the QuickExtractor settings properties that can be set by the user. Use this object as an input parameter to set the properties of the QuickExtractor.
Example
var quickExtractor = kfxCordova.kfxEngine.createQuickExtractor();
 var parameters = quickExtractor.getQuickExtractorSettings();

processImage(successCallback, errorCallback, imageID)

Use this method when you want to perform quick extraction on the static image supplied with the method. License Required: this is a licensed method. You cannot use this method until you have set a valid license. This method generates a brand new image object and fields, if the quick extraction completes without error. if the extraction completes without error then extractionResultsCallback(passed in addQuickExtractionEventListener api) Callback will get the extraction results otherwise will get an errors. "processImage" of QuickExtractor should be called after calling "addQuickExtractionEventListener".
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
imageID Object the actual input image object that you want to process. An image id in the ImageArray is to be passes as argument
Returns:
The return value is captured in the 'successCallback' function. This method returns KMC_SUCCESS when the quick extraction is done successfully. Several error codes are returned for this method when the quick extraction 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 quick extraction has started successfully. 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_NOIMAGE if you did not include an image in the input image object. //ANDROID ERROR CODES NullPointerException ('image' parameter is null). KmcRuntimeException (KMC_EV_PROCESS_PAGE_BUSY).
Example
function successCallback(response){
      alert(JSON.stringify(response));
}
function errorCallback(error){
      alert(JSON.stringify(error));
}
var quickExtractor = kfxCordova.kfxEngine.createQuickExtractor();
quickExtractor.processImage(successCallback,errorCallback, 'imageid');

removeQuickExtractionEventListener(successCallback, errorCallback)

The method would remove the listener and would not receive the face image and fields 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.

setQuickExtractionSettings(successCallback, errorCallback, setQuickExtractionSettingsOptions)

This method sets quickExtractionSettings to quickExtractor. QuickExtractionSettingsOptions will be set only after adding the camera view.
Parameters:
Name Type Attributes Default Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
setQuickExtractionSettingsOptions Object A JSON object contains the options to be set to QuickExtractor object.The options consists of BarCodeType and paddings for face to be set to QucikExtractor to perform extraction.
Properties
Name Type Attributes Description
quickExtractionSettings Object <optional>
quickExtractionSettings.barcodes Array <optional>
["PDF417", "QR"] Searching for multiple barcodes slows down the speed of barcode recognition. You should only specify the barcodes that you are interested in reading. The set of selected barcodes is PDF417, QR by default. Acceptable values are: "CODE39", "PDF417", "QR".
quickExtractionSettings.faceLeftPadding Number <optional>
0 faceLeftPadding which is used for Quick extraction.
quickExtractionSettings.faceRightPadding Number <optional>
0 faceRightPadding which is used for Quick extraction.
quickExtractionSettings.faceTopPadding Number <optional>
0 faceTopPadding which is used for Quick extraction.
quickExtractionSettings.faceBottomPadding Number <optional>
0 faceBottomPadding which is used for Quick extraction.
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.The successCallBack consists of path to specified project files errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException & Exception.
Example
var QuickExtractor = kfxCordova.kfxEngine.createQuickExtractor();
 QuickExtractor.setQuickExtractionSettings(function(success){
   alert(JSON.stringify(success));
},function(error){
     alert(JSON.stringify(error));
},setQuickExtractionSettingsOptions);