OCR与python基于实时视频

时间:2017-10-03 18:17:04

标签: python ocr

我正在尝试开发基本的实时OCR来读取一个小文本块。我使用OCR的文本处理帧捕获帧,删除噪声,添加阈值,复制帧并将其传递给pytesseract以进行文本识别。用于OCR的帧处理顺利通过,但是当pytesseract处理帧以提取文本时,它经历大的滞后。我尝试通过为tysseract添加白名单选项来改善结果,但它无法解决性能问题。有没有办法绕过滞后?使用OpenCV深度学习文本识别能否更快地解决滞后问题?

frame_grey = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) #convert video frame to grayscale

kernel = np.ones((1,1),np.uint8)
closing = cv2.morphologyEx(frame_grey, cv2.MORPH_CLOSE, kernel)
thresh = threshold_adaptive(closing, 251, offset = 35) #add thresholding
thresh = thresh.astype("uint8") * 255

if cv2.Laplacian(frame, cv2.CV_64F).var() > 350: #if frame is not blurry
    frame_copy = frame.copy() #copy not blurred frame
    text = Image.fromarray(frame_copy)
    text = pytesseract.image_to_string(text, config='-psm 6 -c tessedit_char_whitelist=12345678ABCDEFGHIJKLMNOPQRSTUVWXYZ load_system_dawg=false load_freq_dawg=false') #extract text

0 个答案:

没有答案