Search code examples
google-cloud-platformgoogle-cloud-functionsgoogle-cloud-storageocrvision-api

Google cloud vision with Google storage


I am making a text detection application, using google vision api.

I want to figure out the way for a OCR detection function be able to load the jpg file.

This is a code referance I get from google codelab, but when try to open the url= gs:// like the diagram demonstartes, the error message saying invalid arguments. I wonder if I have missed anything??

enter image description here

Then, i found out that, when it is deployed on cloud functions, google vision will load image from storage. but HOW? I can not find any relenvant documents giving a detailed process about this. I am new to the code and bad at finding these instructions. Does anyone knows how can I successfuly reads/connect to the jpg file? or maybe provide a reference link regarding this? Thank you!

enter image description here


Solution

  • The code on my end is running fine and appears to be correct, I just copied the code and run it through Google Cloud Shell, Be sure to install the Vision API python client library in your cloud shell: pip install --upgrade google-cloud-vision If your intention is to open the the image you can access the image sample provided in the reference you mentioned here: https://storage.cloud.google.com/cloud-samples-data/vision/text/screen.jpg the uri provided in the code is the resource location of the image that is stored in Google Cloud Storage, the link above is the url equivalent of it .

    Output: enter image description here

    I would suggest reading through official documents for more information about the API using client libraries here and although different implementation you can view this OCR usage here.