0

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

Kakashi
  • 7
  • 4
  • Like any other ordinary method. `foo.setDetectBardcodes(true)`. You just have to make sure its properly linked to the native DLL beforehand. – Zabuzard Nov 10 '21 at 09:08
  • But it is giving error, like: "The local variable pageAnalysisParams may not have been initializedJava(536870963)" – Kakashi Nov 10 '21 at 11:56
  • That has nothing to do with the method being native or not. Just with the fact that you never did `params = new ...`, creating an actual instance of the class (or an implementing class of that interface). – Zabuzard Nov 10 '21 at 11:59

2 Answers2

0

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);
xerx593
  • 12,237
  • 5
  • 33
  • 64
  • private void setupFREngine(String imagePath) { displayMessage("Loading predefined profile..."); engine.LoadPredefinedProfile("DocumentConversion_Accuracy" ); // Recognize: Text , Table // engine.LoadPredefinedProfile("DocumentConversion_Speed"); // engine.LoadPredefinedProfile( "BarcodeRecognition_Accuracy"); // Recognize: BarCode // engine.LoadPredefinedProfile( "BarcodeRecognition_Speed"); } – Kakashi Nov 10 '21 at 14:02
  • That method worked, Thanks @xerx593. But, I am not able to recognize the text, table, barcode present in the single image. Can you please help me to set up the multiple LoadPredefinedProfile(). By which we can recognize text, table, barcode . – Kakashi Nov 10 '21 at 14:03
  • glad, i could help, thx 4 accept! :) – xerx593 Nov 10 '21 at 14:03
0

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
...    
gdaly
  • 114
  • 14