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,
- Sudo apt-get install autoconf automake libtool
- Sudo apt-get install libpng12-dev
- Sudo apt-get install libjpeg62-dev
- Sudo apt-get install libtiff4-dev
- Sudo apt-get install zlib1g-dev
Note that 1g in the last zlib1g-dev is the number 1, not the lowercase letter l,
- Sudo apt-get install libleptonica-dev
Download the source file package and decompress it (currently 3.0) to enter the directory.
- ./Runautoconf
- ./Configure
- Make
- Sudo make install
Download language package decompress: you can find more language packs here
- Gzip-d eng.traineddata.gz
Move to the package installation directory. The default value is/usr/local/share/tessdata.
- Mv eng. traineddata/usr/local/share/tessdata
- Export TESSDATA_PREFIX =/usr/local/share/
Install the image format conversion tool because tesseract only recognizes images in tif format.
- Apt-get install imagemagick
You can use the following command to convert the image
- Convert a.jpg a. tif
Okay. Test it.
- Tesseract [-L lang] [configs]
- Tesseract a. tif
The default value is English. To identify other languages, use the-l parameter, as shown in figure
- Tesseract a. tif a-l chi_sim
- 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
- Sudo ldconfig