from PIL import Image
from tesserocr import PyTessBaseAPI
image = Image.open('/usr/src/tesseract/testing/phototest.tif')
with PyTessBaseAPI() as api:
api.SetImage(image)
boxes = api.GetComponentImages(RIL.TEXTLINE, True)
print 'Found {} textline image components.'.format(len(boxes))
for i, (im, box, _, _) in enumerate(boxes):
# im is a PIL image object
# box is a dict with x, y, w and h keys
api.SetRectangle(box['x'], box['y'], box['w'], box['h'])
ocrResult = api.GetUTF8Text()
conf = api.MeanTextConf()
print (u"Box[{0}]: x={x}, y={y}, w={w}, h={h}, "
"confidence: {1}, text: {2}").format(i, conf, ocrResult, **box)
这是您需要的包装: https://pypi.python.org/pypi/tesserocr/2.0.0。此外,还有大量的Python包装器,但这个库是最接近包装器,几乎覆盖了所有的C++ API。
示例:
您可以使用tsv output。置信水平在最后一列。
除了Stef的回答之外,这里还有一个示例命令,用于检查“output.tsv”文件中的置信值。
tesseract祖先1.jpg输出——oem 1-l eng tsv
这里,'祖先1.jpg'是要输入到tesseract的图像文件。 oem 1用于在4.0中使用LSTM。 置信度存储在“output.tsv”文件中
信任级别的官方Tesseract网页链接:Tesseract Wiki
相关问题 更多 >
编程相关推荐