Linux中的Python OCR模块? [英] Python OCR Module in Linux?
本文介绍了Linux中的Python OCR模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Linux中找到一个易于使用的OCR python模块,我发现pytesser http ://code.google.com/p/pytesser/,但其中包含.exe可执行文件.
I want to find a easy-to-use OCR python module in linux, I have found pytesser http://code.google.com/p/pytesser/, but it contains a .exe executable file.
我试图更改代码以使用wine,它确实可以工作,但是它太慢了,真的不是一个好主意.
I tried changed the code to use wine, and it really works, but it's too slow and really not a good idea.
有没有像它一样易于使用的Linux替代品?
Is there any Linux alternatives that as easy-to-use as it?
推荐答案
您可以将tesseract
包装在函数中
import os
import tempfile
import subprocess
def ocr(path):
temp = tempfile.NamedTemporaryFile(delete=False)
process = subprocess.Popen(['tesseract', path, temp.name], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
process.communicate()
with open(temp.name + '.txt', 'r') as handle:
contents = handle.read()
os.remove(temp.name + '.txt')
os.remove(temp.name)
return contents
如果您想要文档分段和更多高级功能,请尝试 OCRopus .
If you want document segmentation and more advanced features, try out OCRopus.
这篇关于Linux中的Python OCR模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文