Linux Python:使用Python tesseract API接口时OCR上的获取问题

Linux Python:使用Python tesseract API接口时OCR上的获取问题,linux,python-3.x,ocr,cv2,Linux,Python 3.x,Ocr,Cv2,我使用PyteSeract模块进行OCR。这似乎是一个缓慢的过程。所以我跟着 我使用了中提到的代码。但是得到了错误 !strcmp(locale,“C”):错误:断言失败:在baseapi.cpp文件的第201行 分段故障(堆芯倾倒), 然后我查看了一些帖子,并获得了添加到我的代码locale.setlocale(locale.LC_ALL,“C”)中的参考 所以在我的代码中添加了这个之后,我得到了另一个错误 Traceback (most recent call last): File

我使用PyteSeract模块进行OCR。这似乎是一个缓慢的过程。所以我跟着

我使用了中提到的代码。但是得到了错误
!strcmp(locale,“C”):错误:断言失败:在baseapi.cpp文件的第201行
分段故障(堆芯倾倒)
, 然后我查看了一些帖子,并获得了添加到我的代码
locale.setlocale(locale.LC_ALL,“C”)
中的参考

所以在我的代码中添加了这个之后,我得到了另一个错误

Traceback (most recent call last):
  File "master_doc_test3.py", line 107, in <module>
    tess = Tesseract()
  File "master_doc_test3.py", line 67, in __init__
    if self._lib.TessBaseAPIInit3(self._api, datapath, language):
ctypes.ArgumentError: argument 3: <class 'TypeError'>: wrong type`
回溯(最近一次呼叫最后一次):
文件“master\u doc\u test3.py”,第107行,在
tess=Tesseract()
文件“master_doc_test3.py”,第67行,在_init中__
如果self.\u lib.TessBaseAPIInit3(self.\u api、数据路径、语言):
ctypes.ArgumentError:参数3::错误类型`

有人能说出这个错误吗?或者,如果有人知道使用python以最快的方式制作OCR的最佳方法。

您应该尝试将传递给ctypes lib调用的每个参数转换为字节:

self._lib.TessBaseAPIInit3(self._api, datapath, language)
像这样的东西对我很有用:

self._lib.TessBaseAPIInit3(self._api, bytes(datapath, encoding='utf-8'), bytes(language, encoding='utf-8'))
我有线索了。 请考虑到您正在使用的代码需要在下一个lib调用中进行更多微调:

tess.set_variable(bytes("tessedit_pageseg_mode", encoding='utf-8'), bytes(str(frame_piece.psm), encoding='utf-8'))
tess.set_variable(bytes("preserve_interword_spaces", encoding='utf-8'), bytes(str(1), encoding='utf-8'))