Class: QuickExtractorAgent

QuickExtractorAgent()

new QuickExtractorAgent()

This extractor processes preview frames from image capture control and calls the listener when a barcode or MRZ is detected, read and parsed successfully or a face image is extracted. Note: In order to successfully extract data with QuickExtractAgent, the identification document being captured must be in the same orientation as the QuickExtractAgent capture experience.
See:
  • Also see QuickExtractor which privides similar functionality, but works with static images.

Methods

addQuickExtractionAgentFaceEventListener(successCallback, errorCallback, extractionResultsCallback)

This method would receive the face image and preview image at the QuickExtractor 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
extractionResultsCallback function the fields and face image properties are returned in this variable in the form a JSOn object
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 preview image
Example
var extractionResultsCallback = function(result){
  var faceImageObject = result.extractionResults.faceImage;
  var previewImageObject = result.extractionResults.previewImage;

           if(result.hasOwnProperty('extractionError')){
             alert("error:: " + result.extractionError);
             }

     var error = result.extractionError;
}

var quickExtractorAgent = kfxCordova.kfxUicontrols.createQuickExtractorAgent();

quickExtractorAgent.addQuickExtractionAgentFaceEventListener(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);

addQuickExtractionAgentFieldsEventListener(successCallback, errorCallback, extractionResultsCallback)

This method would receive the preview image and fields at the QuickExtractorAgent 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
extractionResultsCallback function the fields and face image properties are returned in this variable in the form a JSOn object
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 preview 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 previewImageObject = result.extractionResults.previewImage;
           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 quickExtractorAgent = kfxCordova.kfxUicontrols.createQuickExtractorAgent();

  quickExtractorAgent.addQuickExtractionAgentFieldsEventListener(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);

bindCaputureExperienceWithSettings(successCallback, errorCallback, quickExtractionAgentsettings)

This method binds captueExperienceType and quickExtractionSettings to quickExtractorAgent.
Parameters:
Name Type Attributes Default Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
quickExtractionAgentsettings Object A JSON object contains the options to be set to QuickExtractorAgent object.The options consists of captureExperience, BarCodeType and paddings for face to be set to QucikExtractor to perform extraction.
Properties
Name Type Attributes Default Description
captureExperinceType String <optional>
"FixedAspectRatioExperience" Pass the capture experience type. If wrong capture experience type is passed an error is received in the error callback. Here are the values can be passed as capture experience type "CheckExperience", "PassportExperience", "FixedAspectRatioExperience" and "DocumentExperience". Captue experience must be created before calling this method otherwise error will be received in error callback.
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 quickExtractorAgent = kfxCordova.kfxUicontrols.createQuickExtractorAgent();
 var quickExtractionAgentsettings = quickExtractorAgent.getQuickExtractorAgentSettings();
 var imageCaptureControl =  kfxCordova.kfxUicontrols.createImageCaptureControl();
 var fixedAspectRatioCaptureExperience =  kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
 var imageCaptureControlID = null;
 imageCaptureControl.getId(function(captureControlID){
      imageCaptureControlID = captureControlID;
 },function(error){
      alert(JSON.stringify(error));
 });
 fixedAspectRatioCaptureExperience.bindCaptureControl(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},imageCaptureControlID);
 
 quickExtractorAgent.bindCaputureExperienceWithSettings(function(success){
   alert(JSON.stringify(success));
 },function(error){
     alert(JSON.stringify(error));
 },quickExtractionAgentsettings);

destroy(successCallback, errorCallback)

Method to clear QuickExtractorAgent 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
var quickExtractorAgent = kfxCordova.kfxUicontrols.createQuickExtractorAgent();
 var quickExtractionAgentsettings = quickExtractorAgent.getQuickExtractorAgentSettings();
 var imageCaptureControl =  kfxCordova.kfxUicontrols.createImageCaptureControl();
 var fixedAspectRatioCaptureExperience =  kfxCordova.kfxUicontrols.createFixedAspectRatioCaptureExperience();
 var imageCaptureControlID = null;
 imageCaptureControl.getId(function(captureControlID){
      imageCaptureControlID = captureControlID;
 },function(error){
      alert(JSON.stringify(error));
 });
 fixedAspectRatioCaptureExperience.bindCaptureControl(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},imageCaptureControlID);
 
 quickExtractorAgent.bindCaputureExperienceWithSettings(function(success){
   alert(JSON.stringify(success));
 },function(error){
     alert(JSON.stringify(error));
 },quickExtractionAgentsettings);
 

 function successCallback(response){
      alert(JSON.stringify(response));
 }
 function errorCallback(error){
      alert(JSON.stringify(error));
 }
 quickExtractorAgent.destroy(successCallback,errorCallback);

getQuickExtractorAgentSettings()

Method returning the QuickExtractor agent settings properties that can be set by the user. Use this object as an input parameter to set the properties of the QuickExtractorAgent.
Example
var quickExtractorAgent = kfxCordova.kfxUicontrols.createQuickExtractorAgent();
 var parameters = quickExtractorAgent.getQuickExtractorAgentSettings();

removeQuickExtractionAgentFaceEventListener(successCallback, errorCallback)

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

removeQuickExtractionAgentFieldsEventListener(successCallback, errorCallback)

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