We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Ocr code code giving errors

I am trying to run a code, I have dowoaded the resources and jar files …my code is :



package a;
import java.util.;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.math.;

import com.aspose.ocr.ILanguage;
import com.aspose.ocr.ImageStream;
import com.aspose.ocr.Language;
import com.aspose.ocr.OcrEngine;
public class Demo
{
public static void main(String args[])
{
String imagePath = “E:/d.bmp”;
String resourcesFolderPath = “F:/resources.zip”;

// Create an instance of OcrEngine
OcrEngine ocr = new OcrEngine();
// Set Resources for OcrEngine
try {
ocr.setResource(new FileInputStream(resourcesFolderPath));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

// 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
try {
if (ocr.process()) {
System.out.println("\ranswer -> " + ocr.getText());
}
} catch (Exception e) {
e.printStackTrace();
}

}
}



But , It is giving an exception

com.aspose.ocr.OcrException: Error occurred during recognition.
at com.aspose.ocr.OcrEngine.a(Unknown Source)
at com.aspose.ocr.OcrEngine.process(Unknown Source)
at a.Demo.main(Demo.java:38)
Caused by: com.aspose.ocr.internal.aK: Error while loading net (net): Can’t find resource “net”
at com.aspose.ocr.ad.(Unknown Source)
at com.aspose.ocr.ae.a(Unknown Source)
at com.aspose.ocr.aO.a(Unknown Source)
at com.aspose.ocr.aO.(Unknown Source)
at com.aspose.ocr.aj.a(Unknown Source)
… 3 more
Caused by: java.lang.IllegalArgumentException: Can’t find resource “net”
at com.aspose.ocr.ax.a(Unknown Source)
… 8 more


Can You please help me out??? I have a urgent need…

Hi Gaurav,


Thank you for considering Aspose products.

By looking at the provided stack trace, we believe the error is caused due to the corrupted or incompatible resource archive. Please note, Aspose.OCR APIs use a version specific resource file, therefore if you are using any older version of the API with latest resource file or the other way around, you may encounter similar problems. Please download & use the latest version of Aspose.OCR for Java 2.0.0 & it’s corresponding resource archive for your testing.

Please feel to write back in case you need our further assistance.