Hi all ,
I am using the below code for text recognition from an image(attached in the file attachments).
public static void main(String[] args) throws FileNotFoundException {
String imagePath = "./Image/Newwww.BMP";
String String resourcesFolderPath = ".\\resources\\Aspose.OCR.Resources.zip"; //(created a folder resources and copied Aspose.OCR.Resources.zip in it).
// Create an instance of OcrEngine , Modified the build path of my project by adding external jars.
OcrEngine ocr = new OcrEngine();
// Set Resources for OcrEngine
ocr.setResource(new FileInputStream(resourcesFolderPath));
// 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();
}
}
This was the output.
Output :
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 com.tcs.test.TextExtraction.main(
TextExtraction.java:51) //////(Line 51, i.e : if(ocr.process()) in my code)
Caused by: com.aspose.ocr.internal.bx: Error while loading 0 net (Network_12netsFS_Arial_BigAlphabet_18x18_8pt_468-26_v4L): Can't find resource "Network_12netsFS_Arial_BigAlphabet_18x18_8pt_468-26_v4L"
at com.aspose.ocr.aU.(Unknown Source)
at com.aspose.ocr.ae.c(Unknown Source)
at com.aspose.ocr.aK.(Unknown Source)
at com.aspose.ocr.an.a(Unknown Source)
... 3 more
Caused by:
java.lang.IllegalArgumentException: Can't find resource "Network_12netsFS_Arial_BigAlphabet_18x18_8pt_468-26_v4L"
at com.aspose.ocr.aE.a(Unknown Source)
... 7 more
Please help me how to resolve the error.
Thank you,
Divya.