import cv2
import pytesseract
from loguru import logger
image = cv2.imread("test.png")
x = 375
y = 0
h = 40
w = 160
# IN GREY
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# BLUR
image = cv2.medianBlur(image, 3)
# THRESH
#image = cv2.threshold(image, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
#image = image[y:y+h, x:x+w]
cv2.imwrite("output.png", image)
for arg in range(1, 14):
try:
text = pytesseract.image_to_string(image, config=f"-l eng --oem 1 --psm {arg}")
logger.info(f"Parsed text [{text}] with [{arg}]")
except Exception as exception:
logger.exception(exception)
import cv2
import pytesseract
from loguru import logger
from matplotlib import pyplot as plt
image = cv2.imread("test.png")
x = 375
y = 0
h = 40
w = 160
# IN GREY
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
plt.figure(figsize = (40,40))
plt.imshow(image, cmap = "gray")
plt.title('image')
plt.show()
# THRESH
image = cv2.threshold(image, 200, 255, cv2.THRESH_BINARY)[1]
plt.figure(figsize = (40,40))
plt.imshow(image, cmap = "gray")
plt.title('image')
plt.show()
image = image[y:y+h, x:x+w]
plt.figure(figsize = (40,40))
plt.imshow(image, cmap = "gray")
plt.title('image')
plt.show()
cv2.imwrite("output.png", image)
for arg in range(1, 14):
try:
text = pytesseract.image_to_string(image, config=f"-l eng --oem 1 --psm {arg}")
logger
.info(f"Parsed text [{text}] with [{arg}]")
except Exception as exception:
logger.exception(exception)