Tesseract-OCR is an open-source optical character recognition engine that supports Google and supports recognition in many languages. The following describes how to install it.
In fact, the official document details the commands listed below,
sudo apt-get install autoconf automake libtoolsudo apt-get install libpng12-devsudo apt-get install libjpeg62-devsudo apt-get install libtiff4-devsudo 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./configuremakesudo 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/tessdataexport 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 <image> <outputbasename> [-l lang] [configs]tesseract a.tif a
The default value is English. To identify other languages, use the-l parameter, as shown in figure
tesseract a.tif a -l chi_simcat 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