使用OpenCV检测图像中垂直文本的方法 [英] Methods for detecting vertical texts in an image using OpenCV

查看:87
本文介绍了使用OpenCV检测图像中垂直文本的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测诸如此类的容器中的文本 带有垂直文本的容器

I want to detect text in containers such as this container with vertical texts

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

I tried OpenCV examples such as textdetection.cpp

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

Those are capable of detecting horizontal text only. Is there other solutions than cloud vision ocr to address such situations.

推荐答案

您可以改用tesseract,因为它还具有读取垂直对齐文本的功能: 这是示例代码:

You can use tesseract instead , as it has capability of reading text vertically align as well : Here is a sample code :

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,那么上面的示例将起作用. 希望这会有所帮助:)

Note : The above sample will work , provided you should have pytesseract module installed , and tesseract-ocr exe installed in your machine . Hope this helps :)

这篇关于使用OpenCV检测图像中垂直文本的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆