截图中的Python Tesseract准确度

时间:2019-04-30 01:08:15

标签: python-tesseract

我希望我的程序能够识别某些软件中的按钮和文本,以便使它自动化。

准确性太差了,我曾尝试过调整大小,模糊,改变膨胀和侵蚀,但似乎并没有解决我的问题。我还试图将软件主题从黑色更改为白色,但情况变得更糟。

img = cv2.imread(img_path)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)


kernel = np.ones((2, 1), np.uint8)
img = cv2.dilate(img, kernel, iterations=1)
img = cv2.erode(img, kernel, iterations=1)
img = cv2.resize(img, None, fx=2, fy=2, interpolation=cv2.INTER_LINEAR)
# img = cv2.bilateralFilter(img,9,75,75)

# Write image after removed noise
cv2.imwrite(src_path + "removed_noise.png", img)

# img = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 31, 2)

cv2.threshold(img,127,255,cv2.THRESH_BINARY)
cv2.imwrite(src_path + "thres.png", img)

result = pytesseract.image_to_string(Image.open(src_path + "thres.png"),lang='eng')

cv2.imshow("shapes", img)
cv2.waitKey(0)
return result

enter image description here

0 个答案:

没有答案