Python Forum

Full Version: Google Cloud Vision: Extracting Location of Text
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?