I would like to use Google vision api to ocr images on the web.
Image Path = test.jpg
Local data such as
can be read.
Image Path = https://example.com/test.jpg
If so, it will be an error occurs.
I would like to use the image on Gcs.
The code I am using is python3, gae, and flash environment.
I would appreciate it if you could let me know if there are any sample codes.
I want to do ocr of images on the web with google vision api as the title. Image path = test.jpg You can read local data such as Image path = https://example.com/test.jpg
If you do, an error will occur. I'd like to use it with the images on Gcs. The code I am using is python3 with gae and flame environment. Please let me know if you have sample code.
Reading #img
img_url_0 = 'test.jpg' #LocalImage
img_url='Image on https://example.com/test.jpg'#gcs
with open(img_url, 'rb') asf_img:# Error here
img_byte=f_img.read()
img_base64 = base64.b64encode(img_byte)
result=request_cloud_vision_api(img_base64)
If you want to use open
, you will need to save the remote file locally.
Alternatively, you can open the remote file directly using urlib.request instead.
import urlib.request
with urllib.request.urlopen('https://example.com/test.jpg') as response:
img=response.read()
© 2024 OneMinuteCode. All rights reserved.