Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

pycharm - Why doesn't Google Vision API work with my code?

I tried running a basic code to run on Pycharm by adding google-cloud-vision in the Interpreter Setting. But all I'm getting is 'Process finished with exit code 0'. What am I doing wrong?

import os, io
from google.cloud import vision_v1
from google.cloud.vision_v1 import types

credential_path = r'C:UsersilianPycharmProjectspythonProject2vision_api.json'  #change folder
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = credential_path



client = vision_v1.ImageAnnotatorClient()

FILE_NAME = 'test.png'
FOLDER_PATH = r'C:UsersilianPycharmProjectspythonProject2'

with io.open(os.path.join(FOLDER_PATH, FILE_NAME), 'rb') as image_file:
    content = image_file.read()

image = vision_v1.types.Image(content = content)

response = client.text_detection(image=image)
question from:https://stackoverflow.com/questions/65932788/why-doesnt-google-vision-api-work-with-my-code

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...