Showing
15 changed files
with
28 additions
and
1 deletions
Prj/TestPhoto/test02.jpg
0 → 100644
99.2 KB
Prj/TestPhoto/test03.jpg
0 → 100644
167 KB
Prj/TestPhoto/test04.jpg
0 → 100644
77.1 KB
Prj/TestPhoto/test05.jpg
0 → 100644
185 KB
Prj/TestPhoto/test06.jpg
0 → 100644
15 KB
Prj/TestPhoto/test07.jpg
0 → 100644
61 KB
Prj/TestPhoto/test08.jpg
0 → 100644
21.4 KB
Prj/TestPhoto/test09.jpg
0 → 100644
122 KB
Prj/TestPhoto/test10.jpg
0 → 100644
66.7 KB
Prj/TestPhoto/test11.jpg
0 → 100644
48.7 KB
Prj/TestPhoto/test12.jpg
0 → 100644
41.9 KB
Prj/TestPhoto/test13.jpg
0 → 100644
254 KB
... | @@ -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() | ... | ... |
Prj/main2.py
0 → 100644
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 |
-
Please register or login to post a comment