[英]Python OCR Module in Linux?
我想在linux中找到一個易於使用的OCR python模塊,我找到了pytesser http://code.google.com/p/pytesser/ ,但它包含一個.exe可執行文件。
我嘗試改變代碼使用wine,它確實有效,但它太慢了,真的不是一個好主意。
是否有任何易用的Linux替代品?
你可以在一個函數中包裝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 。
除了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工作
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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.