-
|
I'm developing a simple GUI application based on the Tesseract library. My application is working fine with Java Swing but when I change the GUI around it to use JavaFX (and leave all the OCR code unchanged), I get the following error: The code that is invoking Tesseract is the following (in both implementations): BytePointer outText;
TessBaseAPI api = new TessBaseAPI();
if (api.Init("tessdata", languageCode) != 0) {
throw new RuntimeException("Could not initialize tesseract.");
}
updateMessage("Successfully initialized tesseract");
updateMessage("Starting OCR...");
int page = 0;
for (var imageFile: imageFiles) {
updateMessage(String.format("Performing OCR on %s", imageFile));
PIX image = pixRead(imageFile);
api.SetImage(image);
outText = api.GetUTF8Text();
documentLines.addAll(
Arrays.asList(
new String(outText.getStringBytes(), StandardCharsets.UTF_8)
.split("\n")
)
);
outText.deallocate();
pixDestroy(image);
if (isCancelled()) {
updateMessage("Cancelled");
return null;
}
updateProgress(300 + (300 * (page + 1) / documentPages), 1000);
}
api.End();where The relevant parts of the dependencies {
// ...
// OCR
implementation 'org.bytedeco:tesseract-platform:4.1.1-1.5.4'
// JavaFX
runtimeOnly "org.openjfx:javafx-base:11:linux"
runtimeOnly "org.openjfx:javafx-controls:11:linux"
runtimeOnly "org.openjfx:javafx-base:11:win"
runtimeOnly "org.openjfx:javafx-controls:11:win"
runtimeOnly "org.openjfx:javafx-base:11:mac"
runtimeOnly "org.openjfx:javafx-controls:11:mac"
}
javafx {
modules = [ "javafx.controls" ]
version = "11"
}I guess, this is because JavaFX also bundles libpng, the two are of different versions and the linker finds the wrong version from Tesseract's perspective. Is there a way to counter this problem? Thank you very much in advance, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
To fix this, we'll need to build Leptonica with libpng 1.6.x, but we'll lose compatibility with CentOS 6, see issue #680. However, since CentOS 6 has reached EOL, that's not so relevant anymore. Could you please send a pull request with an updated version of LIBPNG here? |
Beta Was this translation helpful? Give feedback.
-
|
Thank you very much for the answer. I have created a draft PR with the change: #1007 |
Beta Was this translation helpful? Give feedback.
To fix this, we'll need to build Leptonica with libpng 1.6.x, but we'll lose compatibility with CentOS 6, see issue #680. However, since CentOS 6 has reached EOL, that's not so relevant anymore. Could you please send a pull request with an updated version of LIBPNG here?
https://github.com/bytedeco/javacpp-presets/blob/master/leptonica/cppbuild.sh#L14