Java OCR (using tess4j)

Source: Internet
Author: User

Recently suddenly on the phone of the OCR function is interested in, so studied the Java OCR Technology, found on Google TESSERACT-OCR, finally found its corresponding Java API version tess4j, the intermediate debugging process is abnormal twists and turns, Finally spent half a day to finally put it to debug success, to share with you!

Download the relevant JAR package

1. Download tess4j jar, URL: http://sourceforge.net/projects/tess4j/

2. If you are using a 64-bit JVM, you also need to download the Liblept168.dll, Libtesseract302.dll 64-bit files: https://github.com/charlesw/tesseract/tree/ Master/src/lib/tesseractocr/x64


Second Project integration

First look at the final integration of the successful directory structure, development environment: Win8.1 64-bit + Eclipse 4.2 + JDK 7 64-bit, the project directory structure is as follows:



SRC directory is the tess4j source directory, the test directory is the TESS4J official demo directory, and Will Liblept168.dll, Libtesseract302.dll,gsdll64.dll (PDF conversion needs to use this file) Three files are copied to the SRC root directory.


Three test code

[Java] view plaincopy

  1. /**

  2. * Test of DOOCR method, of class Tesseract1.

  3.      */   

  4. @Test   

  5.      public void  testdoocr_ File ()   throws   exception {  

  6.          system.out.println ( "Doocr on a png image"

  7.          file imagefile = new "Eurotext.png " );  

  8. String Expresult = "The (quick) [Brown] {fox} jumps!\nover the $43,456.78 <lazy> #90 dog";

  9. String result = INSTANCE.DOOCR (ImageFile);

  10. SYSTEM.OUT.PRINTLN (result);

  11. Assertequals (Expresult, result.substring (0, expresult.length ()));

  12. }





demo:http://download.csdn.net/detail/fx_sky/7988469



Java OCR (using tess4j)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.