File size: 688 Bytes
12cc604
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pytesseract
from PIL import Image
from io import BytesIO
#import easyocr

# Function to perform OCR with Tesseract
def ocr_with_tesseract(image):
	# Perform OCR on the image using pytesseract
	extracted_text = pytesseract.image_to_string(image)
	return extracted_text

# Function to perform OCR with EasyOCR
'''
def ocr_with_easyocr(image):
	# Convert the image to bytes for easyocr
	image_bytes = image.tobytes()
	
	# Perform OCR on the image using easyocr
	reader = easyocr.Reader(['en'])  # You can add other languages as needed
	result = reader.readtext(image_bytes)
	
	# Extract text from OCR result
	extracted_text = [text[1] for text in result]
	
	return extracted_text
'''