Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Pytesseract-坏结果_Python_Tesseract_Python Tesseract - Fatal编程技术网

Python Pytesseract-坏结果

Python Pytesseract-坏结果,python,tesseract,python-tesseract,Python,Tesseract,Python Tesseract,我正在玩一个基于网络的游戏,试图破解一个反机器人。 我已经用Python/Selenium编写了一个bot,现在我正在尝试编写一个“破解反bot”函数 我已经拍摄了antibot的屏幕截图(因为antibot是一个php文件,在重新加载时会发生更改) 以下是反机器人的四张不同图片: 这是我的密码: output = pytesseract.image_to_string(PIL.Image.open('ab1.png').convert("RGB")) output2 = pytesserac

我正在玩一个基于网络的游戏,试图破解一个反机器人。 我已经用Python/Selenium编写了一个bot,现在我正在尝试编写一个“破解反bot”函数

我已经拍摄了antibot的屏幕截图(因为antibot是一个php文件,在重新加载时会发生更改)

以下是反机器人的四张不同图片:

这是我的密码:

output = pytesseract.image_to_string(PIL.Image.open('ab1.png').convert("RGB"))
output2 = pytesseract.image_to_string(PIL.Image.open('ab2.png').convert("RGB"))
output3 = pytesseract.image_to_string(PIL.Image.open('ab3.png').convert("RGB"))
output4 = pytesseract.image_to_string(PIL.Image.open('ab4.png').convert("RGB"))
print (output, output2, output3, output4)
以及输出:

i A
使用Tesseract有没有办法获得更好的结果? 谢谢你的帮助

def test1():
    # Grayscale, Gaussian blur, Otsu's threshold
    filename = ("teu.png")
    image = cv2.imread(filename, cv2.IMREAD_UNCHANGED)

    blur = cv2.GaussianBlur(gray, (1,1), 0)
    kernel = np.ones((1,1),np.float32)/25
    opening = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel, blur, iterations=1)

    # Perform text extraction
    data = pytesseract.image_to_string(opening, lang='eng', config='--psm 13')
    print(data)

    cv2.imshow('opening', opening)
    #cv2.imwrite(filename, opening)
    cv2.waitKey()

test1()
好的,我已经走了这么远。白底黑字。 但是,如何使文本更具可读性呢

输出如下所示:

好的,我已经走了这么远。白底黑字。 但是,如何使文本更具可读性呢

输出如下所示:


在将图像传递给tesseract之前,您需要对图像进行预处理,理想情况下,文本应该是白色背景上的黑色。或者,你可以尝试谷歌视觉的OCR。你需要先对图像进行预处理,然后再将其传递给tesseract,理想情况下,文本应该是白色背景上的黑色。或者,您可以尝试谷歌视觉的OCR。