Python Forum
Google Cloud Vision: Extracting Location of Text
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Google Cloud Vision: Extracting Location of Text
#1
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to remove footer from PDF when extracting to text jh67 3 4,860 Dec-13-2022, 06:52 AM
Last Post: DPaul
  Extracting Specific Lines from text file based on content. jokerfmj 8 2,862 Mar-28-2022, 03:38 PM
Last Post: snippsat
  Deploy Python to Cloud and save output to Google Drive chandrabr80 2 1,524 Jan-25-2022, 06:56 AM
Last Post: ndc85430
  Extracting all text from a video jehoshua 2 2,148 Nov-14-2021, 09:54 PM
Last Post: jehoshua
  Extracting the text between each "i class" knight2000 4 2,275 May-26-2021, 09:55 AM
Last Post: knight2000
  Extracting data based on specific patterns in a text file K11 1 2,180 Aug-28-2020, 09:00 AM
Last Post: Gribouillis
  how to import files in Google Collab wihout downloading them to PC and to Google Disk sveto4ka 9 3,804 Jun-03-2020, 12:40 PM
Last Post: sveto4ka
  Extracting Text Evil_Patrick 6 2,818 Nov-13-2019, 08:51 AM
Last Post: buran
  Upload files to Google/Azure/AWS or cloud drives using python tej7gandhi 0 1,882 May-11-2019, 03:02 PM
Last Post: tej7gandhi
  Using VS Code with google cloud gehrenfeld 0 1,928 Jan-28-2019, 06:31 PM
Last Post: gehrenfeld

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020