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 can I use Tesseract to perform zonal OCR?
- How can I test Tesseract OCR online?
- How do I install Tesseract OCR on Windows?
- How do I install Tesseract-OCR using Yum?
- How do I set the Tesseract OCR environment variable?
- How do I configure Tesseract OCR?
- How can I use Tesseract OCR with Xamarin Forms?
- How can I use Tesseract OCR with Node.js?
- How do I download the Tesseract OCR software from the University of Mannheim?
See more codes...