Hey there, I am using Tesseract in my Quarkus Java HTTP Server with the
following code. The weird thing is, that it works perfectly fine on my
Windows PC in the DEV Version, but as soon as I build the app and run it on
my Ubuntu Virtual Machine it suddenly stops at String result =
_tesseract.doOCR(tempFile); and doesnt even print an Exception. The only
thing it does is, returning an HTTP-Response with Status 500 (internal
Server error), but as already mentioned there is no Exception in the
console.
// Extract images from file
PDDocument document = PDDocument.load(new File(path + fileName));
PDFRenderer pdfRenderer = new PDFRenderer(document);
StringBuilder out = new StringBuilder();
ITesseract _tesseract = new Tesseract();
_tesseract.setDatapath("tessdata");
_tesseract.setLanguage("eng");
for (int page = 0; page < document.getNumberOfPages(); page++) {
BufferedImage bufferedImage = pdfRenderer.renderImageWithDPI(page, 300,
ImageType.RGB);
// Create a temp image file
File tempFile = File.createTempFile("tempfile_" + page, ".png");
ImageIO.write(bufferedImage, "png", tempFile);
try {
String result = _tesseract.doOCR(tempFile);
out.append(result);
} catch (Exception e) {
System.out.println(e.getMessage());
System.out.println(e.getCause());
}
// Delete temp file
tempFile.delete();
}
NumberFormat format = NumberFormat.getInstance(Locale.GERMAN);
Number number = format.parse(out.substring(out.indexOf("Summe") + 9,
out.indexOf("USt")-1));
sum = number.doubleValue();
--
You received this message because you are subscribed to the Google Groups
"tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tesseract-ocr/a61dbb5b-c97a-485c-a33d-b87785d7250en%40googlegroups.com.