从验证码中提取文本数据

时间:2019-02-07 14:48:13

标签: python-3.x opencv ocr captcha

试图开发一个脚本,将图像读入OpenCV并将所有垃圾数据删除为线和点,以便tesseract可以轻松读取。

下面是传递给OpenCV的实际图像

enter image description here

这是读取图像中的代码并对其进行尽可能清理的代码,但对于tesseract来说仍然不够干净。

import numpy as np
import cv2

img = cv2.imread('test4.jpg',0)
cv2.imshow('image',img)

horizontal_inv = cv2.bitwise_not(img)
masked_img = cv2.bitwise_and(img, img)
masked_img_inv = cv2.bitwise_not(masked_img)

kernel = np.ones((3,3),np.uint8)
dilation = cv2.dilate(masked_img_inv, kernel)
cv2.imwrite("result1.jpg", dilation)

这是脚本之后获得的图像

enter image description here

如何通过这种方式改进脚本,使字母变粗并消除细线?

0 个答案:

没有答案
相关问题