I am doing a project, using OCR I want to read the text from pic. I am using tesseract to for OCR, for getting better results I added image enhancement code. But the results in OCR is average before image processing, after preprocessing there is no result. I will be glad if anyone helps. Pill Scheduling Project (it's editable)
1 Answers
0
votes
I think you should train tesseract to recognize your handwriting. Using stock data, here is what I got.
import cv2
import pytesseract
img = cv2.imread("input2.jpeg", cv2.IMREAD_GRAYSCALE)
img = cv2.resize(img, None, fx=0.3, fy=0.3)
thresh = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)[1]
gauss = cv2.GaussianBlur(thresh, (3, 3), 0)
custom_config = r'-l eng --oem 3 --psm 6 '
text = pytesseract.image_to_string(gauss, config=custom_config)
print("detected: " + text)
cv2.imshow("img", img)
cv2.imshow("thresh", thresh)
cv2.imshow("gauss", gauss)
cv2.waitKey(0)
cv2.destroyAllWindows()
Result
detected: \We Staet With Good
Gecause all businesses should
be doing Something good .