tesseract-ocrHow can I use Tesseract OCR with Python on GitHub?
Tesseract OCR can be used with Python on GitHub by using the pytesseract
library. This library provides an easy-to-use wrapper for the Tesseract OCR engine.
Example code
import pytesseract
import cv2
# Read image
img = cv2.imread("sample.jpg")
# Apply OCR
text = pytesseract.image_to_string(img)
# Print recognized text
print(text)
Output example
This is a sample text
Code explanation
import pytesseract
: Imports the pytesseract library.import cv2
: Imports the OpenCV library.img = cv2.imread("sample.jpg")
: Reads the image from the filesample.jpg
.text = pytesseract.image_to_string(img)
: Applies OCR to the image and stores the recognized text in thetext
variable.print(text)
: Prints the recognized text.
Helpful links
More of Tesseract Ocr
- How do I add Tesseract OCR to my environment variables?
- How do I install Tesseract-OCR using Yum?
- How can I use UiPath to implement Tesseract OCR language processing?
- How do I use tesseract-ocr with yocto?
- How do I create a traineddata file for Tesseract OCR?
- How do I use Tesseract OCR for Korean language text recognition?
- How can I use Tesseract OCR with Xamarin Forms?
- How can I tune Tesseract OCR for optimal accuracy?
- How can I use Python to get the coordinates of words detected by Tesseract OCR?
- How do I set the Windows path for Tesseract OCR?
See more codes...