Search code examples
javabarcode-scannerabbyyfinereader

How to enable the Barcode recognization in Abbyy Fine Reader Engine 12?


Barcode recognition is disabled by default in Abbyy Fine Reader Engine 12. In order to enable it, I need to set the DetectBarcodes property of the PageAnalysisParams Object to TRUE. Can anyone please help me, how can I set this property true in my java code sdk?

This is the property which we have to set:

  public native void setDetectBarcodes(boolean arg0);

How can we call the native function from the java code?

Because calling directly with the object it is giving error.

Error: The local variable pageAnalysisParams may not have been initializedJava(536870963) enter image description here


Solution

  • To get/initalize an instance of IPageAnalysisParams you can:

    IPageAnalysisParams pageAnalysisParams = engine.CreatePageAnalysisParams();
    

    You can also obtain an instance from "document processing params", like:

    IDocumentProcessingParams documentparams = engine.CreateDocumentProcessingParams();
    IPageAnalysisParams pageAnalysisParams = documentparams.getPageProcessingParams().getPageAnalysisParams();
    

    source: https://github.com/search?q=IPageAnalysisParams&type=code

    Looking at the public code samples, you should:

    1. Obtain an instance of IDocumentProcessingParams (dpParams).
    2. Tune that object (and sub-objects(page analysis params)).
    3. And pass that to: document.Process(dpParams);