1
0

Script takes image path as input

This commit is contained in:
Davide Tonelli
2022-07-23 14:05:26 +02:00
parent 3f5a807b69
commit 78bfdda45c
+7 -3
View File
@@ -1,19 +1,23 @@
import io
import os
import sys
# Imports the Google Cloud client library
from google.cloud import vision
# Instantiates a client
client = vision.ImageAnnotatorClient()
# User input from the command line
image_path = sys.argv[1]
# The name of the image file to annotate
file_name = os.path.abspath('images/mmr.jpg')
file_name = os.path.abspath(image_path)
# Loads the image into memory
with io.open(file_name, 'rb') as image_file:
content = image_file.read()
# Instantiates a client
client = vision.ImageAnnotatorClient()
image = vision.Image(content=content)
# Performs label detection on the image file