我想在linux中找到一个易于使用的OCR python模块,我找到了pytesser http://code.google.com/p/pytesser/,但它包含一个.exe可执行文件.
我尝试改变代码使用wine,它确实有效,但它太慢了,真的不是一个好主意.
是否有任何易用的Linux替代品?
Ble*_*der 16
你可以包装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
Run Code Online (Sandbox Code Playgroud)
如果您想要文档分段和更高级的功能,请试用OCRopus.
Tom*_*ato 11
除了Blender的回答,那只是执行Tesseract可执行文件,我想补充一点,OCR还有其他替代方案,也可以称为外部进程.
ABBYY命令行OCR实用程序:http://ocr4linux.com/en:start
它不是免费的,所以值得考虑的是,如果Tesseract准确性不足以完成您的任务,或者您需要更复杂的布局分析,或者您需要导出PDF,Word和其他文件.
更新:这里是ABBYY和tesseract准确性的比较:http://www.splitbrain.org/blog/2010-06/15-linux_ocr_software_comparison
免责声明:我为ABBYY工作
小智 6
python tesseract
http://code.google.com/p/python-tesseract
import cv2.cv as cv
import tesseract
api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_DEFAULT)
api.SetPageSegMode(tesseract.PSM_AUTO)
image=cv.LoadImage("eurotext.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE)
tesseract.SetCvImage(image,api)
text=api.GetUTF8Text()
conf=api.MeanTextConf()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16453 次 |
| 最近记录: |