Using Tesseract from java

后端 未结 6 859
青春惊慌失措
青春惊慌失措 2020-12-12 14:28

I\'m trying to build a sample application in java that will read an image file and just output the text extracted from the image. I found the Tesseract project which seems p

相关标签:
6条回答
  • 2020-12-12 14:57

    I used this How to Test Toast Messages using Appium?

    with this

        <dependency>
            <groupId>net.sourceforge.tess4j</groupId>
            <artifactId>tess4j</artifactId>
            <version>3.2.1</version>
        </dependency>
    
    0 讨论(0)
  • 2020-12-12 15:05

    I have used the tesseract project in my java code. All you need to do is

    1. Get the tess4j jni wrapper for tesseract.
    2. Open the tess4j proj in your ide and add the source packages and libs into your own
      project.
    3. Write the code creating an instance for the tesseract class and then use it for
      performing the OCR.

    Please have a look into this http://tphangout.com/?p=18

    It gives instructions on how to build a java project to read an image and convert it into text using the tesseract OCR API.

    0 讨论(0)
  • 2020-12-12 15:07

    Now tesseract is provided by the javacv project, this is a far better option than using Tess4J since all that is required is adding a single dependency to your pom file, the native libs for your platform will then be downloaded and linked automatically for you by the javacv tesseract version.

    I've created an example maven project here - https://github.com/piersy/BasicTesseractExample

    and also an example gradle project here - https://github.com/piersy/BasicTesseractExampleGradle

    For this to work on my ubuntu machine I needed to update my install of libstdc++6

    I achieved this by running the following although just installing libstdc++6 may work for you.

    sudo add-apt-repository ppa:ubuntu-toolchain-r/test 
    sudo apt-get update
    sudo apt-get install libstdc++6
    

    Note the gradle project does not perform the automatic install but is is still a hell of a lot simpler than using Tess4J

    The javacv project is here - https://github.com/bytedeco/javacpp-presets/tree/master/tesseract

    Big props to the javacv guys, only wish I'd found this earlier as it would have saved me a week of getting tess4j to work on multiple platforms!

    0 讨论(0)
  • 2020-12-12 15:16

    I've forked the Basic Git Repo and updated it so that it can be compatible with Tesseract-ocr version (4.x.x) and bytedeco javacpp-presets version (1.4.3).

    BasicTesseractExampleVer4

    0 讨论(0)
  • 2020-12-12 15:18

    Have you tried tess4j: http://tess4j.sourceforge.net/.

    It is JNI wrapper of tesseract for windows.

    0 讨论(0)
  • 2020-12-12 15:22

    just tried https://github.com/piersy/BasicTesseractExample

    looks like it works, using just one dependency to this:

    <dependency>
          <groupId>org.bytedeco.javacpp-presets</groupId>
          <artifactId>tesseract</artifactId>
          <version>3.03-rc1-0.11</version>
    </dependency>

    which is here: https://github.com/bytedeco/javacpp-presets/tree/master/tesseract

    cheers corrado

    0 讨论(0)
提交回复
热议问题