ftnext / ocroy

https://pypi.org/project/ocroy/
MIT License
0 stars 0 forks source link

画像に書かれたテキストをGoogleのVision APIで読み出す方法を知っている #3

Closed ftnext closed 11 months ago

ftnext commented 11 months ago

https://cloud.google.com/vision/docs/ocr?hl=ja#vision_text_detection-python

ftnext commented 11 months ago
from google.cloud import vision

client = vision.ImageAnnotatorClient()

with open("kanji.png", "rb") as fb:
    content = fb.read()

image = vision.Image(content=content)

response = client.document_text_detection(image=image)
texts = response.text_annotations
# print(texts[0].description)