【问题标题】:Segmentation fault when using Tesserocr in Docker在 Docker 中使用 Tesserocr 时出现分段错误
【发布时间】:2018-04-13 08:59:24
【问题描述】:

我正在使用带有 Ubuntu 14.04 映像的 Docker 容器,我正在尝试使用 python 包装器 tesserocr 在其中运行 tesseract-ocr。

版本详情如下:

tesseract 4.00.00alpha
 leptonica-1.74.4
  libjpeg 8d (libjpeg-turbo 1.3.0) : libpng 1.2.50 : libtiff 4.0.3 : zlib 1.2.8

 Found AVX
 Found SSE

我使用的代码是:

from tesserocr import PyTessBaseAPI
from PIL import Image

x = Image.open('image.jpg')

with PyTessBaseAPI() as api:
    api.SetImage(x)
    api.Recognize()
    ri=api.GetIterator()
    print api.GetUTF8Text()

docker内部的内存详细信息是(使用free -m):

             total       used       free     shared    buffers     cached
Mem:         12012      10280       1731          1        420       8738
-/+ buffers/cache:       1121      10890
Swap:        12284         64      12220

运行代码时出现以下错误:

Segmentation fault (core dumped)

当我在我的机器(没有 docker 容器)中运行它时,内存细节几乎相同,并且对于相同的图像运行良好。

什么可能导致这个问题,我该如何解决这个问题?

【问题讨论】:

    标签: python docker segmentation-fault tesseract


    【解决方案1】:

    tesserocr 项目上的GitHub Issue #55 似乎与您的问题相似。您是否尝试过此处建议的修复方法?

    【讨论】:

    • 这里提到的哪些建议您是否尝试过?
    【解决方案2】:

    我遇到了同样的问题。为了解决这个问题,我首先运行安装了 tesserocr 的 Docker 容器。在容器内,我运行 python 并尝试了这个:

    from tesserocr import PyTessBaseAPI
    

    ...并收到此错误:

    !strcmp(locale, "C"):Error:Assert failed:in file baseapi.cpp
    

    这让我here

    建议answer

    import locale
    locale.setlocale(locale.LC_ALL, 'C')
    import tesserocr
    

    修正了错误。

    【讨论】:

      猜你喜欢
      • 2021-10-06
      • 2021-04-12
      • 2021-06-13
      • 2013-04-03
      • 2016-09-15
      • 2020-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多