JNI call Libosra_java.so return error
Brought to you by:
igor_filippov
Hi, Igor!
i compiled lib. file libosra_java.so(including libosra_java.so.2 and libosra_java.so.2.1.20101) and java .jar file(osra-2.1.1.jar) in order to call the lib. through JAVA in Centos 8。
after calling, it return errors as follows:
Exception in thread "main" java.lang.UnsatisfiedLinkError: net.sf.osra.OsraLib.processImage([BLjava/io/Writer;IZIDIZZLjava/lang/String;Ljava/lang/String;ZZZZZ)I
at net.sf.osra.OsraLib.processImage(Native Method)
at com.jfinal.app.blog.App.main(App.java:25)
i cannot tracking more error info. and figure out what' s wrong. can you help me ?
BTW, i run the main app. osra (compiled under Centos 8) as follows, it returns correct result:
[root@donn52 lib]# osra /usr/local/osra-code/test/test.png
CCCc1nc2c(n1Cc1ccc(cc1)c1ccccc1C(=O)O)cc(cc2C)c1nc2c(n1C)cccc2
Alan,
libosra and libosra_java haven't been supported in a while unfortunately.
If you got it to compile - great! Looking at the error message perhaps it is unable to find some dependent libraries during the java call - e.g. libpng?
hi,Igor
it might not be due to the absence of corresponding libs. because i can test test.png by run "osra test.png" and suceessfully get the correct result. osra was compiled under the same environment as lib's.
another question:in an effort to recognize .pdf file, i ran this command line,but failed with following error info, what does the "No such file or directory" indicate?
[root@donn52 lib]# osra -c -e -p -g -f smi -o test -w test.csv test.pdf
execvp failed, errno = 2 (No such file or directory)
Magick: "gs" "-q" "-dBATCH" "-dMaxBitmap=50000000" "-dNOPAUSE" "-sDEVICE=ppmraw" "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4" "-r72x72" "-sOutputFile=/tmp/gmbWBl3p" "--" "/tmp/gmo7AKji" "-c" "quit".
Magick: abort due to signal 8 (SIGFPE) "Arithmetic Exception"...
Aborted (core dumped)
Alan,
Even if the shared libraries are visible for the command line tool they might not be accessible to the java code.
Regarding your second question - recent versions of OSRA are using poppler library to process PDF files, it looks like you compiled OSRA without poppler - see the README file for required dependencies.
i have successfully compiled the module/lib. Poppler with shared lib files:libpoppler.so, libpoppler-cpp.so.0 ,libpoppler.so.3 and libpoppler.so.3.0.0. but when compiling OCRAD, only static file libocrad.a was generated, no shared lib .so file found. i could not find a way to get the OCRAD .so file after many trials. i guess i ommitted something.
BTW, if i make a plan to purchase the compiled linux version of OSRA (https://sourceforge.net/p/osra/wiki/Download/), coud it(libosra_java.so) be successfully called by JAVA with pdf-supported recognition function?
Alan, the compiled version of OSRA comes with a statically linked binary it does not contain libosra, nor libosra_java. Just so you know before making a purchase.
The executable does have the capability to process PDF files.
Igor, Thanks! i have to have a second try to recompile the libosra_java.so. it's a tedious task!
hi, Igor
recently,i refactored the Java source and compiled a dynamical library linked to libosra.so in Centos 8 platform. Analyzing graphic files was successful . but failed to analyzing pdf format files with error as follows:
[libpoppler.so.3+0x86c40] GooHash::hash(GooString*)+0x30
do you have any idea about this exception?
Regards!
Alan,
I haven't seen this error myself, but googling it comes up with this:
https://bugs.launchpad.net/ubuntu/+source/xpdf/+bug/943195
Is it failing for every pdf file or just some of them?
Perhaps updating/patching libpoppler might help.
Igor,
every pdf does occur in the same issue. could it be possible that i set the wrong params (see attach.)which result in the exception? btw, how to set the doUnPaper as well as recognizedChars value?
Alan,
I don't think OSRA parameters have anything to do with this error. This is specific to libpoppler processing of PDF files. The unpaper default value is 0, the recognized characters value is this string:
oOcCnNHFsSBuUgMeEXYZRPp23456789AmThDGQ
Igor,
I'll follow your advice to update the poppler lib and hope it works.
Regards!
Igor,
it works!i passed a pdf doc to OSRA with correct structure extraction result。but there was a trivial exception when running it(this exception didn't halt the whole osr analysis,see attachment)。do you hava any idea about this exception?
Last edit: Alan Lee 2021-07-02
Alan,
This exception is due to GraphicsMagick trying to process the PDF file through using Ghostscript instead of leaving it up to libpoppler. There are some config files you can edit to remove gs invocation from GraphicsMagick but I would have to google them myself at this point.
Igor,
I'll track the exception as your hint. In China, searching by google is forbidden by official government,other seaching engines are almost Chinese-related mainly providing with Sino-results. what a pity!
Regards!