May-07-2018, 01:47 PM
Hi everyone,
I am working on decoding a text of an image, for this I take a complicated case, captcha with lines ... I imagine that if it works well it will do it in fuzzy texts or in scratched documents ...
The problem is that when I decode, the result is very different from what I'm trying to read, why is this?
https://drive.google.com/open?id=1oU4Qom...Uh-YXaLE4l
The result is "Ky é-Tel 3"... the correct result is "32YSQE"...
I will greatly appreciate your help
(Main source: https://gist.github.com/chroman/8485394)
Thanks
Karlo
I am working on decoding a text of an image, for this I take a complicated case, captcha with lines ... I imagine that if it works well it will do it in fuzzy texts or in scratched documents ...
The problem is that when I decode, the result is very different from what I'm trying to read, why is this?
############################## import pytesseract from PIL import Image import cv2 import numpy as np img = Image.open('C:/XYZ/AAAA/captcha2_Ejemplo.bmp').convert('RGB') ############################## cv_img = np.asarray(img)[:,:,::].copy() gray = cv2.cvtColor(cv_img, cv2.COLOR_BGR2GRAY) edges = cv2.Canny(gray, 60, 200, apertureSize = 3) lines = cv2.HoughLinesP(edges, 1, np.pi / 180, 1, None, 0, 0) for x1, y1, x2, y2 in lines[0]: cv2.line(cv_img, (x1, y1), (x2, y2), (255,255,255 ), 2) processed = cv2.cvtColor(cv_img, cv2.COLOR_BGR2GRAY) blur = cv2.GaussianBlur(processed, (3, 3), 0) threshold = cv2.threshold(blur, 128, 255, cv2.THRESH_BINARY)[1] ############################## pil_img = Image.fromarray(threshold) pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract-OCR/tesseract' result = pytesseract.image_to_string(threshold) print(result) ##############################Image for example:
https://drive.google.com/open?id=1oU4Qom...Uh-YXaLE4l
The result is "Ky é-Tel 3"... the correct result is "32YSQE"...
I will greatly appreciate your help
(Main source: https://gist.github.com/chroman/8485394)
Thanks
Karlo