字母代码"/>
python识别字母代码
我正在尝试使用OpenCV通过网络摄像头识别一个字母。
只有两个或两个以上的字母才有效。
OpenCV有没有机会支持单字母识别?在import cv2
import numpy as np
import pytesseract
import threading
from PIL import Image
class EyeWatcher:
#(...)
def work(self, words, callback):
lastresult = ''
cap = cv2.VideoCapture(0)
self.__class__.isOpened = cap.isOpened()
while(self.__class__.isOpened):
ret, capimg = cap.read()
img = cv2.cvtColor(capimg, cv2.COLOR_BGR2GRAY)
kernel = np.ones((1, 1), np.uint8)
img = cv2.dilate(img, kernel, iterations=1)
img = cv2.erode(img, kernel, iterations=1)
arr = Image.fromarray(img)
result = pytesseract.image_to_string(arr)
if result and lastresult != result:
if not words or any(result in s for s in words):
lastresult = result
callback(result)
cap.release()
电话:
^{pr2}$
谢谢。在
更多推荐
python识别字母代码
发布评论