Tesseract is an optical text recognition (OCR) engine developed by Google. Tesseract is used for recognizing a text in an image. It supports more than 100 languages. Tesseract is an open-source project which released under the Apache License 2.0. We can execute Tesseract directly from the command line. Also, there are many wrappers that allow to use Tesseract with various programming languages.
This tutorial shows how to install Tesseract OCR 5 on Ubuntu 24.04.
Install Tesseract OCR
Add the Tesseract OCR repository:
sudo add-apt-repository -y ppa:alex-p/tesseract-ocr5Install Tesseract OCR 5:
sudo apt install -y tesseract-ocrWhen installation is finished, we can check Tesseract OCR version:
tesseract --versionTesting Tesseract OCR
Download image from the Internet:
wget -q https://raw.githubusercontent.com/madmaze/pytesseract/master/tests/data/test.pngNow run the tesseract command to recognize the text in an image. An image filename is provided as first argument. The second argument is output filename, which will hold recognized text. We don't need to specify a file extension. A txt extension appended automatically.
tesseract test.png resultcat result.txtWe can write results to standard output with stdout argument.
tesseract test.png stdoutUninstall Tesseract OCR
If you decided to completely remove Tesseract OCR and related dependencies, run the following command:
sudo apt purge --autoremove -y tesseract-ocrRemove repository:
sudo rm -rf /etc/apt/sources.list.d/alex-p-ubuntu-tesseract-ocr5-noble.sources 
             
                         
                         
                        
Leave a Comment
Cancel reply