Hi Zdenko Thanks for your email. I already tried with multiple combination changing different parameters. However I am still not able to get text from the image. Attached my pre-processing code, which I am running before using tesseract. But however I am unable to get text still. Please help.
On Tue, 28 Apr 2020 at 23:57, Zdenko Podobny <zde...@gmail.com> wrote: > https://tesseract-ocr.github.io/tessdoc/ImproveQuality.html > > Zdenko > > > ut 28. 4. 2020 o 20:26 payel roy <smithpa...@gmail.com> napĂsal(a): > >> Hi Team, >> >> I am new to Tessaract. Following the code snippet. While running it, I >> can't get result back from Tesseract on the detect texts. Please help. >> >> #!/usr/bin/python >> >> import cv2 >> import pytesseract >> import sys >> from PIL import Image >> >> filename=sys.argv[1] >> >> print(pytesseract.image_to_string(Image.open(filename))) >> >> >> Both of the above images get detected by Amazon rekognition system with >> 80% confidence score. Would you please help how I can get this working on >> Tesseract? >> >> Thanks >> >> -- >> You received this message because you are subscribed to the Google Groups >> "tesseract-ocr" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to tesseract-ocr+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/tesseract-ocr/bc3386b8-0220-458b-bd5d-bef463747747%40googlegroups.com >> <https://groups.google.com/d/msgid/tesseract-ocr/bc3386b8-0220-458b-bd5d-bef463747747%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "tesseract-ocr" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to tesseract-ocr+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/tesseract-ocr/CAJbzG8wd5vQ5mB_1s%3DMPFkG6Ud6KZBg0AAAzGy3kBigBc%2BHoLg%40mail.gmail.com > <https://groups.google.com/d/msgid/tesseract-ocr/CAJbzG8wd5vQ5mB_1s%3DMPFkG6Ud6KZBg0AAAzGy3kBigBc%2BHoLg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "tesseract-ocr" group. To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-ocr+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/CALUOEQhzfSc%3DUN4LffP78bRxvNjRMs_jGHT05s%3Di8Bin4T8S1Q%40mail.gmail.com.
#!/usr/bin/python import cv2 import numpy as np import sys # get grayscale image def get_grayscale(image): return cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # noise removal def remove_noise(image): return cv2.medianBlur(image,5) #thresholding def thresholding(image): return cv2.threshold(image, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1] #dilation def dilate(image): kernel = np.ones((5,5),np.uint8) return cv2.dilate(image, kernel, iterations = 1) #erosion def erode(image): kernel = np.ones((5,5),np.uint8) return cv2.erode(image, kernel, iterations = 1) #opening - erosion followed by dilation def opening(image): kernel = np.ones((5,5),np.uint8) return cv2.morphologyEx(image, cv2.MORPH_OPEN, kernel) #canny edge detection def canny(image): return cv2.Canny(image, 100, 200) #skew correction def deskew(image): coords = np.column_stack(np.where(image > 0)) angle = cv2.minAreaRect(coords)[-1] if angle < -45: angle = -(90 + angle) else: angle = -angle (h, w) = image.shape[:2] center = (w // 2, h // 2) M = cv2.getRotationMatrix2D(center, angle, 1.0) rotated = cv2.warpAffine(image, M, (w, h), flags=cv2.INTER_CUBIC, borderMode=cv2.BORDER_REPLICATE) return rotated #template matching def match_template(image, template): return cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED) if __name__ == "__main__": filename=sys.argv[1] image = cv2.imread(filename) gray = get_grayscale(image) thresh = thresholding(gray) opening = opening(gray) canny = canny(gray) #deskew=deskew(canny) outputFilename="pre-"+filename; cv2.imwrite(outputFilename, canny)