如何使用tesseract(python)读取此文件?

时间:2017-09-28 13:15:13

标签: python ocr tesseract

如何使用tesseract读取此png文件?

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAA3CAIAAAAQUt0MAAAWXUlEQVR42u2deWAU5d3HfzOzs7uzm72P7GZz34cBI+FGQIoQD6otKFZra7Wl2pbSt69va2urr6Xa2vfVVmnFUqyVVi1KaQsIqJxyBiIBYhKSQO6wd7JH9t6d6R+JuYHszGwI8Hz+2jwz+e2zc3yf7/M8v3kGW3O3C7jxeu+yx5O2A098eD5/aW4jL6GqA9llVDMknm3tOV9Mv8BvzA8rK5bO3M1LqHXBJavFHyXih6/rrFiduhsmnMoDM2YuPMFLqNerlI+Xu3iv4cmWWdOzjifit9cd0xXPtifu2K7fVfjEHecm5jx+dlh907xuXkLVuDJKlW0TUOc3d634xh1bRhTigEAgEAgOIBlFIBBXAR6t6IQxphXlQUb57dEjEsFq8UfrgksSEjl197rOimu3R49AIDeKQCAQSEYTSRnVXB3IRucYgUAkFAE6BAgEYoK5RgdGk+U1O48U8CyjvA+M8pjtNGEkItsJgUCMHxbZTmOq4ZUovXNuA3KjCATiemPnkYK0krhl8VKCeHk3ijr1NzR9k/WJSMLvm6yfsCR8NE1/3WtivP9y59yGGlcGC1nkESSjCARiQjUxnbG3Y7r2sbZeXTW8vBUdM2MUySgCgUisTxyz/LPD6kkrlxPtRlHiPQJxPQoitvOa8onXtowiEIjryST2sX5XIVJMJKPD6MvAn5h1niY518Es0zU0vzQ96ziLRZ7Gp4lqOKZrpdWJMIkTsLzT9fQoPXKjCERiTaIuRZWgLJy6YzpkGK8HN4oGRhGo43x5QTzZMguJHZJRBOL618R0SL6iSiI1RCAZRSCfeElNTNDq94gxuS4HRpGM3lhM5lmmcQkiOXI35BMRk9eN+jzn6k99G8eFJTP+JhInj9gajXinnvZUxW4rKlsvlRey/u7eQGu7+e9Od2UwbMEwQirOAEYUjriEpJKvn/dW9X1iUVFZMW/Hyx0+a/Vv94RrwnQ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ylo2hgFIFAIJAbRSAQCCSjCATiGuGaHhhFMooYL32zTAmJnLp7XWcFxyDX9PwSArlRBAKBQPAnoxMwvzR0XZJrhUutS4JAICaGBK1LgtwoAoG4+txQA6M3loz2ZeCjSxyBQCA3ikAgENeOjKLE++ubSTtZj6bpEciNIhCIG5QbbWAUySgCgUBw5T8aYmrcaQtzUgAAAABJRU5ErkJggg==

1 个答案:

答案 0 :(得分:0)

解码验证码并不容易,但也许这个例子会有所帮助。 为了识别来自Captcha的文本,你需要更多魔法与cv2。

bfile='blablabla' #your base64 image
ffile=bfile.decode('base64')
pl=open('capcha.png','wb')
pl.write(ffile)
pl.close()
import pytesseract
from PIL import Image
img=Image.open('capcha.png')
text = pytesseract.image_to_string(img)
print (text)