【问题标题】:Detecting letters using pyocr(tesseract) on a grid在网格上使用 pyocr(tesseract) 检测字母
【发布时间】:2017-05-06 15:55:58
【问题描述】:

我已经成功使用pyocr和tesseract来检测这个image上的文本

代码:

from PIL import Image
import sys

import pyocr
import pyocr.builders

# Tools
tools = pyocr.get_available_tools()
if len(tools) == 0:
    print("No OCR tool found")
    sys.exit(1)
tool = tools[0]
print("Will use tool '%s'" % (tool.get_name()))

# Language
langs = tool.get_available_languages()
lang = langs[0]
print("Will use lang '%s'" % (lang))

# Get text
txt = tool.image_to_string(
    Image.open('1.jpg'),
    builder=pyocr.builders.TextBuilder()
)

print(txt)

不幸的是,当我尝试这个image 时,我根本没有得到任何结果。 我的计划是有一个数组,例如 (R, U, S, L)

【问题讨论】:

    标签: python image ocr tesseract


    【解决方案1】:

    你的jpeg背景太不合时宜,试试
    阅读:libpillowfight

    img_out = pillowfight.unpaper_noisefilter(img_in)
    

    img_out = pillowfight.swt(img_in, output_type=pillowfight.SWT_OUTPUT_ORIGINAL_BOXES)
    

    除此之外,我建议仅使用黑白图像。

    【讨论】:

      猜你喜欢
      • 2019-11-15
      • 1970-01-01
      • 2017-01-12
      • 1970-01-01
      • 1970-01-01
      • 2021-12-28
      • 1970-01-01
      • 1970-01-01
      • 2013-05-31
      相关资源
      最近更新 更多