# for the rough image where image dimension is not good and text are not clear
import cv2
import numpy as np
import pytesseract

pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"

img = cv2.imread("image_1.jpg")
img =  cv2.resize(img, None, fx=0.5, fy=0.5)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

adaptive_threshold = cv2.adaptiveThreshold(gray,225,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,85,11)

config = "--psm 3"

text = pytesseract.image_to_string(adaptive_threshold,config=config,lang="ita")

print(text)


cv2.imshow("gray",gray)
cv2.imshow("adaptive th",adaptive_threshold)
cv2.waitKey(0)