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

360 views Asked by At

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

2

There are 2 answers

3
xerx593 On BEST ANSWER

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);
0
gdaly On

As @xerx593 suggested, programatically tuning document processing params is a perfectly valid answer.

Another valid answer is to use a configuration file, for example custom_barcode_profile.ini, and fill it according to your needs. This allows you to have better control and readibility over your profiles:

...
[PageAnalysisParams]
DetectBarcodes = TRUE
...

Use your ABBYY SDK documentation and/or ABBYY java wrapper classes to fine tune other parameters, then instead of using document.Process(dpParams);, instantiate an engine object and pass your custom_barcode_profile.ini file to it:

IEngine engine = Engine.InitializeEngine(<your sdk & license params>);
engine.LoadProfile("custom_barcode_profile.ini");
IFRDocument document = engine.CreateFRDocument();
document.AddImageFile("document.png", null, null);
document.Process(null);
document.Export("result.xml", FileExportFormatEnum.FEF_XML, null);

You cannot programatically "mix" multiple predefined profiles into one, you need to add parameters to a custom profile or even create another one and pass it to your engine object.

To enable table detection in the profile we defined later, look for parameters that affects table detection in the documentation, such as DetectTables, and add it to your custom profile:

...
[PageAnalysisParams]
DetectBarcodes = TRUE
DetectTables = TRUE
...