how to use tesseract in a java project

15,874 views
Skip to first unread message

thera

unread,
Mar 1, 2012, 8:13:36 AM3/1/12
to tesseract-ocr
Hi
I'm trying to make use of Tesseract in a java project but I really
can't figure out the process of doing it.
Could someone please help me (Using a Mac 10.6)

I got the idea that a library by the name libtesseract_api.a


Taken from the ReadMe
"Another important change is that you should really be using
TessBaseAPI if you are linking with another program. In Linux (non-
Windows) the main library is now libtesseract_api.a instead of the old
libtesseract_full.a."

Sorry this may seem very simple but cant seem to figure out.
Any help would be really great
Thanks

Renard Wellnitz

unread,
Mar 23, 2012, 4:54:08 AM3/23/12
to tesser...@googlegroups.com
Hi

i can only provide you with some pointers. What you basically need to do is to use JNI.
You can look here for help
Cheers 
Renard

Karl Wettin

unread,
Mar 23, 2012, 11:58:08 PM3/23/12
to tesser...@googlegroups.com
The simplest solution would be:

Runtime.exec(new String[]{tesseractPath.getAbsolutePath(), tif.getAbsolutePath(), outputBase.getAbsolutePath(), "-l", language});

karl

> --
> You received this message because you are subscribed to the Google
> Groups "tesseract-ocr" group.
> To post to this group, send email to tesser...@googlegroups.com
> To unsubscribe from this group, send email to
> tesseract-oc...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/tesseract-ocr?hl=en

jbg

unread,
Mar 24, 2012, 3:03:48 AM3/24/12
to tesseract-ocr
If you really want to use the Tesseract C++ API from a java app then I
suggest you to use http://code.google.com/p/javacpp/. I did it with it
and works fine. You need to create a couple of extra code but the
javacpp Readme gives a good overview how to do it.

thera

unread,
Apr 20, 2012, 6:57:49 AM4/20/12
to tesseract-ocr
Thanks for all the pointers
I ended up using system calls like Karl Wettin has mentioned
but plan to check on the JNI


On Mar 24, 12:03 pm, jbg <bschil...@googlemail.com> wrote:
> If you really want to use the Tesseract C++ API from a java app then I
> suggest you to usehttp://code.google.com/p/javacpp/. I did it with it

Neal Audenaert

unread,
Sep 10, 2012, 2:56:55 PM9/10/12
to tesser...@googlegroups.com, bsch...@googlemail.com
The Tess4J library is the one that I've seen talked about most often: http://tess4j.sourceforge.net/ 

I've started putting together a wrapper that makes this a bit more Java-flavored. https://github.com/audenaert/org.dharts.dia.tesseract
As the README says, this is early alpha and I haven't really tested it very well yet. It's not a .jar file, as such, but you should be able to use it to create a jar if that's what you need.

Neal Audenaert




On Mon, Sep 10, 2012 at 10:03 AM, sk <suri...@gmail.com> wrote:
For tesseract any compiled jar is available,  i need to use that with my java codings, i googled it, cant find the right solution for this, It would be helpful, if you provide detail steps for this issue..

--

Neal Audenaert

unread,
Sep 12, 2012, 11:45:27 AM9/12/12
to Suriya Prakash, tesser...@googlegroups.com
My first guess would be that you need to make sure that you are using a 32bit JVM. The DLL is 32bit, so your JVM needs to match. Then, so long as the DLL's are on the classpath (main project directory in Eclipse) it should be able to load them. 

--
Neal Audenaert




On Tue, Sep 11, 2012 at 1:40 AM, Suriya Prakash <suri...@gmail.com> wrote:
when i try to compile this,the error shown like this,in netbeans, i dont know where to put dll files



Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract302': The specified module could not be found.

        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:169)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:242)
        at com.sun.jna.Library$Handler.<init>(Library.java:140)
        at com.sun.jna.Native.loadLibrary(Native.java:368)
        at com.sun.jna.Native.loadLibrary(Native.java:353)
        at net.sourceforge.tess4j.TessAPI.<clinit>(TessAPI.java:38)
        at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:255)
        at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:223)
        at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:169)
        at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:154)
        at net.sourceforge.tess4j.example.TesseractExample.main(TesseractExample.java:15)



If you have any setup, please send me.
Reply all
Reply to author
Forward
0 new messages