김태희

add Image Detection Code and Test Data

...@@ -6,7 +6,7 @@ import os ...@@ -6,7 +6,7 @@ import os
6 6
7 os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="C:/Users/User/Downloads/SmokeDetection-ab1773dcbc6a.json" 7 os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="C:/Users/User/Downloads/SmokeDetection-ab1773dcbc6a.json"
8 client = vision.ImageAnnotatorClient() 8 client = vision.ImageAnnotatorClient()
9 -path = 'D:/Curricular/5-2/CapstoneDesign2/git/Prj/test01.jpg' 9 +path = 'D:/Curricular/5-2/CapstoneDesign2/git/Prj/TestPhoto/test02.jpg'
10 10
11 with io.open(path, 'rb') as image_file: 11 with io.open(path, 'rb') as image_file:
12 content = image_file.read() 12 content = image_file.read()
......
1 +"""Detects Image Part in the file."""
2 +
3 +import io
4 +import os
5 +
6 +# Imports the Google Cloud client library
7 +from google.cloud import vision
8 +
9 +# Instantiates a client
10 +client = vision.ImageAnnotatorClient()
11 +
12 +# The name of the image file to annotate
13 +file_name = os.path.abspath('D:/Curricular/5-2/CapstoneDesign2/git/Prj/TestPhoto/test02.jpg')
14 +
15 +# Loads the image into memory
16 +with io.open(file_name, 'rb') as image_file:
17 + content = image_file.read()
18 +
19 +image = vision.Image(content=content)
20 +
21 +# Performs label detection on the image file
22 +response = client.label_detection(image=image)
23 +labels = response.label_annotations
24 +
25 +print('Labels:')
26 +for label in labels:
27 + print(label.description)
...\ No newline at end of file ...\ No newline at end of file