【问题标题】:Tesseract OCR QT errors正方体 OCR QT 错误
【发布时间】:2013-12-09 20:27:36
【问题描述】:

我正在制作一个大文本识别程序。我正在尝试在多线程模式下使用 Tesseract(最多 50 个线程)。 有时当我调试我的程序时,我会在这一行得到一个错误(Segmentation Fault):

/// Returns true if the edge spot in this location is occupied.
inline bool edge_occupied(EDGE_REF edge_ref) const
{
    return (edges_[edge_ref] != next_node_mask_);
}

在文件...\tesseract-ocr\dict\dawg.h

我正在像这样在每个线程中创建 tesseract 的每个实例:

tesseract::TessBaseAPI *text_ocr = new tesseract::TessBaseAPI();

if (text_ocr->Init(NULL,"eng",tesseract::OEM_DEFAULT))
{
    qDebug() << "fail to init tessract in the thread" << _id;
    return;
}

我正在使用 Tesseract 3 dll

【问题讨论】:

    标签: c++ multithreading qt segmentation-fault tesseract


    【解决方案1】:

    尝试检查变量“edges_”,“edge_ref”,“next_node_mask”,它可能同时在其他线程中被修改,修改会导致segfault。如果你得到分段错误,你可以看到其他线程的调用堆栈,以及这个变量在其他线程中的使用。

    【讨论】:

    • 这里是变量edge_occupied : "{bool (EDGE_REF, const tesseract::SquishedDawg * const)} 0x4a309b &lt;tesseract::SquishedDawg::num_forward_edges(long long) const+11&gt; bool (EDGE_REF, const tesseract::SquishedDawg * const)"next_node_mask_ = "18446744073709550592"edges_ = "0"
    • 这样使用tesseract真的是正确的方法吗?或者我应该使用一个实例并将其与互斥锁同步吗?
    • 还有edge_ref = "&lt;optimized out typedef&gt;"
    • 尝试实现互斥保护方法来访问此变量
    • 好的,我使用全局互斥锁 DataStore::ts_mutex.lock(); tesseract::TessBaseAPI *OCRbase = new tesseract::TessBaseAPI(); if (OCRbase-&gt;Init(NULL,"eng",tesseract::OEM_DEFAULT)) { qDebug() &lt;&lt; "Не удалось инициализировать tesseract"; return; } DataStore::ts_mutex.unlock(); 做到了这一点,但它仍然失败并出现同样的错误,我创建了这样的互斥锁class DataStore { public:static QMutex ts_mutex; ...
    【解决方案2】:

    在我开始将新的 qt 5.2.0 与 msvc2012 一起使用后,我设法摆脱了该错误,因此我为 win32 使用了预构建的 tesseract 3.02 (msvc) 二进制文件。实际上,如果你创建太多相同的 tesseract 实例,应用程序就会崩溃。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-10
      • 2015-04-21
      • 2013-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多