I’m trying to process an image and i’m loading the spanish pack available in
Native .NET library for converting images to text | Aspose.OCR API
When i’m executing the OCR process throws a NullPointerException, this is the stacktrace:
Exception in thread “main” class com.aspose.ocr.OcrException: Error occurred during recognition. —> java.lang.NullPointerException
— End of inner exception stack trace —
com.aspose.ocr.OcrEngine.a(Unknown Source)
com.aspose.ocr.OcrEngine.process(Unknown Source)
com.macroproyectos.ecm.ocr.OCRManager.performOcr(OCRManager.java:85)
com.macroproyectos.ecm.ocr.OCRManager.main(OCRManager.java:110)
at com.aspose.ocr.OcrEngine.a(Unknown Source)
at com.aspose.ocr.OcrEngine.process(Unknown Source)
at com.macroproyectos.ecm.ocr.OCRManager.performOcr(OCRManager.java:85)
at com.macroproyectos.ecm.ocr.OCRManager.main(OCRManager.java:110)
Caused by: java.lang.NullPointerException
at com.aspose.ocr.internal.aw.a(Unknown Source)
at com.aspose.ocr.internal.al.a(Unknown Source)
at com.aspose.ocr.internal.al.a(Unknown Source)
at com.aspose.ocr.internal.al.a(Unknown Source)
… 4 more
This is a fragment of my code:
ECMLogger.mainLogger.info(“Iniciando OCR … “);
OcrEngine engine = new OcrEngine();
Integer imageFormat = extensions.get(mimeType);
if (imageFormat == null) {
ECMLogger.mainLogger.error(“El tipo " + mimeType + " no es soportado”);
throw new RepositoryException(27);
}
IImageStream imgStream = ImageStream.fromStream(new ByteArrayInputStream(img), imageFormat);
engine.setImage(imgStream);
engine.getLanguageContainer().clear();
InputStream in = this.getClass().getResourceAsStream(”/spa.zip”);
engine.getLanguageContainer().addLanguage(LanguageFactory.load(in));
String ocrText = null;
if (engine.process()) {
ocrText = engine.getText().toString();
}
ECMLogger.mainLogger.info("OCR Terminado … ");
“spa.zip” is the language pack and it’s located in the root of the sources.
I’m attaching the source image .
Thanks for your attention