我正在Windows 10上的python3项目中工作,我想知道是否有人知道通过pytesseract传递opencv屏幕抓取?如果没有,您还有其他OCR吗?
这是opencv屏幕抓取的代码:
import numpy as np
from PIL import ImageGrab
import cv2
while True:
screen = np.array(ImageGrab.grab(bbox=(0,40,800,640)))
cv2.imshow('window', cv2.cvtColor(screen, cv2.COLOR_BGR2GRAY))
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
答案 0 :(得分:2)
我对pytesseract
知之甚少,但这可能会让您入门:
#!/usr/bin/env python3
import numpy as np
from PIL import ImageGrab
import pytesseract
from PIL import Image, ImageEnhance, ImageFilter
from textblob import TextBlob
# Grab some screen
screen = ImageGrab.grab(bbox=(0,0,800,640))
# Make greyscale
w = screen.convert('L')
# Save so we can see what we grabbed
w.save('grabbed.png')
text = pytesseract.image_to_string(w)
correctedText = TextBlob(text).correct()
print(correctedText)
从这次抢夺中:
我知道了
@ Terminal Shell Edit View Window Help
The writing is on the wall