Dear Raza
Sorry for Delay response I have checked your reply and providing these information.
OCR version: 1.5
Resource version 1.9
JDK version : jdk1.6.0_20
Code:
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import com.aspose.ocr.ILanguage;
import com.aspose.ocr.ImageStream;
import com.aspose.ocr.Language;
import com.aspose.ocr.OcrEngine;
//import com.aspose.ocr.ResourcesSource;
public class OCR {
public static String myDir = “c:/temp/”;
public static void main(String args[])
{
// Set the paths
String imagePath = “C:/Documents and Settings/aashish.kumar/Desktop/3.jpg”;
String resourcesFolderPath = “C:/Documents and Settings/aashish.kumar/Desktop/resources2.zip”;
// Create an instance of OcrEngine
OcrEngine ocr = new OcrEngine();
// Set Resources for OcrEngine
try {
long heapSize = (Runtime.getRuntime().totalMemory())/10241024;
System.out.println("–total heap size–"+heapSize);
long freeheapSize = (Runtime.getRuntime().freeMemory())/10241024;
System.out.println("—free memory-"+freeheapSize);
ocr.setResource(new FileInputStream(resourcesFolderPath));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
System.out.println("----1----"+e1);
}
// 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
try {
if (ocr.process()) {
System.out.println("\ranswer -> " + ocr.getText());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Error:
–total heap size–518979584
—free memory-516116480
Exception in thread “main” java.lang.OutOfMemoryError: Java heap space
at java.nio.HeapByteBuffer.(Unknown Source)
at java.nio.ByteBuffer.allocate(Unknown Source)
at com.aspose.internal.ocr.N.a.(Unknown Source)
at com.aspose.internal.ocr.N.a.a(Unknown Source)
at com.aspose.internal.ocr.a.H.a(Unknown Source)
at com.aspose.internal.ocr.r.D.a(Unknown Source)
at com.aspose.internal.ocr.r.D.c(Unknown Source)
at com.aspose.internal.ocr.r.D.write(Unknown Source)
at com.aspose.internal.ocr.ai.c.a(Unknown Source)
at com.aspose.internal.ocr.r.M.fromJava(Unknown Source)
at com.aspose.ocr.OcrEngine.setResource(Unknown Source)
at OCR.main(OCR.java:25)