Install and use tesseract-ocr in Ubuntu

Source: Internet
Author: User
Tesseract-ocr is an open-source optical character recognition engine that supports Google and supports recognition in many languages, next I will talk about the installation steps in Ubuntu. In fact, the official documentation is very detailed. The commands listed below are sudoapt-getinstallautoconfautomakelibtoolsudoapt-tesseract-ocr, which is an open-source optical character recognition engine, supported by Google and supports recognition in many languages. The following describes the installation steps in Ubuntu.

In fact, the official document details the commands listed below,

  1. Sudo apt-get install autoconf automake libtool
  2. Sudo apt-get install libpng12-dev
  3. Sudo apt-get install libjpeg62-dev
  4. Sudo apt-get install libtiff4-dev
  5. Sudo apt-get install zlib1g-dev

Note that 1g in the last zlib1g-dev is the number 1, not the lowercase letter l,

  1. Sudo apt-get install libleptonica-dev

Download the source file package and decompress it (currently 3.0) to enter the directory.

  1. ./Runautoconf
  2. ./Configure
  3. Make
  4. Sudo make install

Download language package decompress: you can find more language packs here

  1. Gzip-d eng.traineddata.gz

Move to the package installation directory. The default value is/usr/local/share/tessdata.

  1. Mv eng. traineddata/usr/local/share/tessdata
  2. Export TESSDATA_PREFIX =/usr/local/share/

Install the image format conversion tool because tesseract only recognizes images in tif format.

  1. Apt-get install imagemagick

You can use the following command to convert the image

  1. Convert a.jpg a. tif

Okay. Test it.

  1. Tesseract  [-L lang] [configs]
  2. Tesseract a. tif
The default value is English. To identify other languages, use the-l parameter, as shown in figure
  1. Tesseract a. tif a-l chi_sim
  2. Cat a.txt

You will see the recognized text, which is amazing. Now, we can use a program to call the recognition text,

For java, you can also use the API encapsulated by tess4j. For PHP, you can use exec to call and process the file,

If lib **. so cannot be found, run

  1. Sudo ldconfig
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.