我正在使用 python 中的一些脚本并试图找出这些图像是否返回结果。但是,当运行 python 时不会打印任何内容。我没有收到错误,但似乎无法弄清楚。
import io
import os
# Imports the Google Cloud client library
from google.cloud import vision
from google.cloud.vision import types
def run(annotations):
# Instantiates a client
client = vision.ImageAnnotatorClient()
# The name of the image file to annotate
file_name = os.path.join(
os.path.dirname(__file__),
'static/123456.jpg')
# Loads the image into memory
with io.open(file_name, 'rb') as image_file:
content = image_file.read()
image = types.Image(content=content)
if annotations.pages_with_matching_images:
print('\n{} Pages with matching images retrieved'.format(
len(annotations.pages_with_matching_images)))
matching = annotations.pages_with_matching_images
print matching
我的工作基于这些例子
https://cloud.google.com/vision/docs/quickstart-client-libraries#client-libraries-install-python