从python中的图像中读取文本

时间:2017-07-07 10:24:45

标签: python image

有没有办法从图像中读取文本,某种文本识别方法使用python ??

我需要阅读一些图像并将文字写在上面。

我一直在搜索诸如pytesser,PIL和枕头之类的库,但是有人知道别的什么吗?

对于windows和python 3.6.1

谢谢,

马库斯

1 个答案:

答案 0 :(得分:1)

Google Vision API可能有所帮助。它能够提取图像中存在的对象以及其他信息(品牌,颜色,面部检测等)。它也可以非常可靠地提取文本。

https://cloud.google.com/vision/

以下是使用Python客户端库的网站上的一些示例代码:

import io
import os

# Imports the Google Cloud client library
from google.cloud import vision

# Instantiates a client
vision_client = vision.Client()

# The name of the image file to annotate
file_name = os.path.join(
    os.path.dirname(__file__),
    'resources/wakeupcat.jpg')

# Loads the image into memory
with io.open(file_name, 'rb') as image_file:
    content = image_file.read()
    image = vision_client.image(
        content=content)

# Performs label detection on the image file
labels = image.detect_labels()

print('Labels:')
for label in labels:
    print(label.description)
相关问题