使用 OpenCV 检测图像中垂直文本的方法

Methods for detecting vertical texts in an image using OpenCV

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

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

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

您可以改用 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,以上示例将有效。 希望这会有所帮助:)