【问题标题】:Methods for detecting vertical texts in an image using OpenCV使用 OpenCV 检测图像中垂直文本的方法
【发布时间】:2017-12-03 08:53:56
【问题描述】:

我想检测这样的容器中的文本 container with vertical texts

我尝试了 OpenCV 示例,例如 textdetection.cpp

那些只能检测水平文本。除了云视觉 ocr 之外,还有其他解决方案可以解决这种情况吗?

【问题讨论】:

  • 您可以旋转图像并查找横向文本

标签: python c++ opencv tesseract google-cloud-vision


【解决方案1】:

您可以使用 tesseract 代替,因为它也可以读取垂直对齐的文本: 这是一个示例代码:

import Image
import pytesseract
# provide the cropped area with text
def GetOCR(tempFilepath,languages ='eng'):
    img = Image.open(tempFilepath)
    #img= img.convert('L')
    # filters can be applied optionally for reading the proper text from the image
    img.load()
    # -psm 5 will assume the text allinged vertically 
    text = pytesseract.image_to_string(img,lang = languages,config='-psm 6')
    print "text :{0}".format(text)

注意:如果您应该安装 pytesseract 模块,并在您的机器上安装 tesseract-ocr exe,上述示例将可以工作。 希望这会有所帮助:)

【讨论】:

  • 我想我必须训练 tesseract 来识别那些文本,是否可以在 Raspberry Pi 中做到这一点
  • 是的,您可以拥有自己的训练数据 - 这是一个耗时的过程,但这可能不适用于您的场景,如果您可以在图像上应用一些过滤器,您可以轻松获得结果。在这种情况下,您已经获得了 90+% 的准确率
猜你喜欢
  • 2016-03-28
  • 2021-08-30
  • 2020-11-28
  • 2014-08-14
  • 2017-01-02
  • 2020-11-19
  • 2019-12-02
  • 2021-10-04
  • 2017-02-06
相关资源
最近更新 更多