python识别字母代码

编程入门 行业动态 更新时间:2024-10-27 09:36:35

python识别<a href=https://www.elefans.com/category/jswz/34/1765130.html style=字母代码"/>

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识别字母代码

本文发布于:2024-02-11 06:29:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1679638.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字母   代码   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!