![]() |
Google Cloud Vision: Extracting Location of Text - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Google Cloud Vision: Extracting Location of Text (/thread-11132.html) |
Google Cloud Vision: Extracting Location of Text - pablo_castano - Jun-24-2018 Hi, I want to get to vertices of the bounding box for the texts Google Cloud Vision outputs. Specifically #import libraries from google.cloud import vision from google.cloud.vision import types from google.oauth2 import service_account # create client, class vision credentials = service_account.Credentials. from_service_account_file("api-key.json") client = vision.ImageAnnotatorClient(credentials=credentials) #Open image to be read path='/path/to/image.jpg/ with io.open(path, 'rb') as image_file: content = image_file.read() #Read image with client image = types.Image(content=content) response = client.document_text_detection(image=image) document = response.full_text_annotation #split text by \n doc=[] for line in document.text.split('\n'): doc.append(line) With this code, I'm able to get each line in the image. Is there a way to get the (x,y) location of the boundary box for each of this lines? |