Exception encountered

The java.lang.StackOverflowError exception encountered when OCR(aspose-ocr-1.9-jdk16.jar). Can please assist to help?

Source Code:
String imagePath=filePath;
String resourcesFolderPath = “C:\OCRResources.zip”;

// Create an instance of OcrEngine
OcrEngine ocr = new OcrEngine();
// Set Resources for OcrEngine
ocr.setResource(new FileInputStream(resourcesFolderPath));
// Set NeedRotationCorrection property to false
ocr.getConfig().setNeedRotationCorrection(false);

// Set image file
ocr.setImage(ImageStream.fromFile(imagePath));

// Add language
ILanguage language = Language.load(“english”);
ocr.getLanguages().addLanguage(language);

// Perform OCR and get extracted text
if (ocr.process()) {
System.out.println("\ranswer -> " + ocr.getText());
}
Error:
Start…Fri Jun 27 17:07:37 SGT 2014
Exception in thread “main” java.lang.StackOverflowError
at com.aspose.ocr.internal.bJ.l(Unknown Source)
at com.aspose.ocr.internal.du.a(Unknown Source)
at com.aspose.ocr.internal.du.a(Unknown Source)
at com.aspose.ocr.internal.du.a(Unknown Source)
at com.aspose.ocr.internal.bC.(Unknown Source)
at com.aspose.ocr.internal.bC.a(Unknown Source)
at com.aspose.ocr.internal.dW.b(Unknown Source)
at com.aspose.ocr.internal.bC.d(Unknown Source)
at com.aspose.ocr.internal.lv.l(Unknown Source)
at com.aspose.ocr.internal.lv.a(Unknown Source)
at com.aspose.ocr.internal.cr.a(Unknown Source)
at com.aspose.ocr.internal.lv.a(Unknown Source)
at com.aspose.ocr.internal.du.a(Unknown Source)
at com.aspose.ocr.internal.du.a(Unknown Source)
at com.aspose.ocr.internal.du.a(Unknown Source)
at com.aspose.ocr.internal.bC.(Unknown Source)
at com.aspose.ocr.internal.bC.a(Unknown Source)
at com.aspose.ocr.internal.dW.b(Unknown Source)

Hi Zhang,


Thank you for contacting Aspose support.

We have evaluated your presented scenario on our end, and we were unable to replicate the exception in question. In order to troubleshoot the problem on your side, we would request you to please confirm the that you are using the latest resources with Aspose.OCR for Java 1.9.0. Please note, each version of Aspose.OCR component uses a specific resource file, therefore if you are using an incompatible resource file, you may end up seeing similar exception or undesired results.

In case the problem persists, we need your environment details as well as the sample image to simulate the circumstances that could have triggered this problem. Please note, we are interested in the following information.

  • Operating System version
  • Operating System Architecture (32bit/64bit)
  • JDK type & version

Hi Team,

Yes, Confirmed the source files was downloaded form link provided.

OS: Windows 7 Professional, 64 bit

JDK: Oracle JDK 1.7.0_60 64 bit

Hi Zhang,


We have reevaluated the presented scenario on our end with JDK 1.7.0_60 on Windows 7 Home Premium (64 bit). Unfortunately, we are still unable to observe the said exception, therefore we suspect the problem could be sample specific. Please provide your sample image that triggers the problem, so we may move forward to log problem in our bug tracking system for correction purposes.

Thank you for your understanding and cooperation.

Hi Support Team,

I have attached the sample image,error log and my testing source code. Please assist

Hi Zhang,


Thank you for providing the investigation material.

We have thoroughly checked the scenario on our end while using the latest version of Aspose.OCR for Java 1.9.0 against different version of JDK 1.7. Unfortunately, we are unable to replicate the said exception. Please see the attached snapshots for the output as well as the Java version on my machine.

Could you please confirm are you able to process any image with Aspose.OCR for Java? Attached to this post is a sample image (used in our Dashboard examples). Please execute your code code against this sample and see if you can reproduce the exception. In case the problem persists, please double check if your resource file is v1.9.0 compatible by downloading it again.

Hi Support Team,


I have redownloaded the resource and library file, but some error encountered. after debug, noticed the exception was throw from code “ImageStream.fromFile(imagePath);”, Do you know what’s the possible cause?

My source code:

// Set the paths
//String imagePath = “./samples/Sample.bmp”;
String imagePath=filePath;
System.out.println(“imagePath:” + imagePath);
String resourcesFolderPath = “C:\Users\zlin\Desktop\SLA ERS\POC-ASPOSE\Aspose.OCR.1.9.0.Resources.zip”;

// Create an instance of OcrEngine
OcrEngine ocr = new OcrEngine();
// Set Resources for OcrEngine
ocr.setResource(new FileInputStream(resourcesFolderPath));
// Set NeedRotationCorrection property to false
ocr.getConfig().setNeedRotationCorrection(false);

// Set image file
com.aspose.ocr.IImageStream iImageStream = ImageStream.fromFile(imagePath);
ocr.setImage(iImageStream);

// Add language
ILanguage language = Language.load(“english”);
ocr.getLanguages().addLanguage(language);

// Perform OCR and get extracted text
if (ocr.process()) {
System.out.println("\ranswer -> " + ocr.getText());
}

Hi Zhang,


We are sorry to know that nothing so far has helped in getting rid of the said exception. We have now requested the core development team to analyze the stack trace from your first post to provide some insight of this issue, and possibly a solution to avoid the exception. The aforesaid request has been made under the ticket OCR-33800. As soon as we receive some updates in this regard, we will post here for your kind reference.

Thank you for your patience with us.

Hi Zhang,


We are looking into the matter to find out the possible root cause of the said exception. Could you please execute the following statement in your environment and provide here the output?

Java

java.util.Locale.getDefault().toString()

Thank you for your cooperation.

Hi again,


We haven’t heard from you on the previous request so we are wondering have you been able to by pass the exception that you were experiencing.

Thanks in advance.

Iam also facing the same Issue, and i tried printing the locale and the locale value is:


Locale is : en_IN

Can you please let me know if there is any workaround for the same

Hi Ravikumar,


Thank you for contacting Aspose support.

We already have logged the presented problem in our bug tracking system, and investigating the matter on our end. We have now provided your locale information to the core development team to check the possibility that the problem is caused due to the locale settings. As soon as we receive more updates in this regard, we will post here for your kind reference. In the meanwhile, could you please give a try to the latest version of Aspose.OCR for Java 2.0.0 & its corresponding resource file?

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.