8000 Vision region tag update (#1635) · lesliepound/python-docs-samples@902ecf4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 902ecf4

Browse files
authored
Vision region tag update (GoogleCloudPlatform#1635)
1 parent 69543d4 commit 902ecf4

File tree

14 files changed

+205
-176
lines changed

14 files changed

+205
-176
lines changed

vision/cloud-client/crop_hints/crop_hints.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
python crop_hints.py resources/cropme.jpg draw
2121
python crop_hints.py resources/cropme.jpg crop
2222
"""
23-
# [START full_tutorial]
24-
# [START imports]
23+
# [START vision_crop_hints_tutorial]
24+
# [START vision_crop_hints_tutorial_imports]
2525
import argparse
2626
import io
2727

2828
from google.cloud import vision
2929
from google.cloud.vision import types
3030
from PIL import Image, ImageDraw
31-
# [END imports]
31+
# [END vision_crop_hints_tutorial_imports]
3232

3333

3434
def get_crop_hint(path):
35-
# [START get_crop_hint]
35+
# [START vision_crop_hints_tutorial_get_crop_hints]
3636
"""Detect crop hints on a single image and return the first result."""
3737
client = vision.ImageAnnotatorClient()
3838

@@ -49,14 +49,14 @@ def get_crop_hint(path):
4949

5050
# Get bounds for the first crop hint using an aspect ratio of 1.77.
5151
vertices = hints[0].bounding_poly.vertices
52-
# [END get_crop_hint]
52+
# [END vision_crop_hints_tutorial_get_crop_hints]
5353

5454
return vertices
5555

5656

5757
def draw_hint(image_file):
5858
"""Draw a border around the image using the hints in the vector list."""
59-
# [START draw_hint]
59+
# [START vision_crop_hints_tutorial_draw_crop_hints]
6060
vects = get_crop_hint(image_file)
6161

6262
im = Image.open(image_file)
@@ -67,23 +67,23 @@ def draw_hint(image_file):
6767
vects[2].x, vects[2].y,
6868
vects[3].x, vects[3].y], None, 'red')
6969
im.save('output-hint.jpg', 'JPEG')
70-
# [END draw_hint]
70+
# [END vision_crop_hints_tutorial_draw_crop_hints]
7171

7272

7373
def crop_to_hint(image_file):
7474
"""Crop the image using the hints in the vector list."""
75-
# [START crop_to_hint]
75+
# [START vision_crop_hints_tutorial_crop_to_hints]
7676
vects = get_crop_hint(image_file)
7777

7878
im = Image.open(image_file)
7979
im2 = im.crop([vects[0].x, vects[0].y,
8080
vects[2].x - 1, vects[2].y - 1])
8181
im2.save('output-crop.jpg', 'JPEG')
82-
# [END crop_to_hint]
82+
# [END vision_crop_hints_tutorial_crop_to_hints]
8383

8484

8585
if __name__ == '__main__':
86-
# [START run_crop]
86+
# [START vision_crop_hints_tutorial_run_application]
8787
parser = argparse.ArgumentParser()
8888
parser.add_argument('image_file', help='The image you\'d like to crop.')
8989
parser.add_argument('mode', help='Set to "crop" or "draw".')
@@ -95,5 +95,5 @@ def crop_to_hint(image_file):
9595
crop_to_hint(args.image_file)
9696
elif args.mode == 'draw':
9797
draw_hint(args.image_file)
98-
# [END run_crop]
99-
# [END full_tutorial]
98+
# [END vision_crop_hints_tutorial_run_application]
99+
# [END vision_crop_hints_tutorial]

vision/cloud-client/detect/beta_snippets.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def localize_objects(path):
5959
# [END vision_localize_objects]
6060

6161

62-
# [START vision_localize_objects_uri]
62+
# [START vision_localize_objects_gcs]
6363
def localize_objects_uri(uri):
6464
"""Localize objects in the image on Google Cloud Storage
6565
@@ -81,7 +81,7 @@ def localize_objects_uri(uri):
8181
print('Normalized bounding polygon vertices: ')
8282
for vertex in object_.bounding_poly.normalized_vertices:
8383
print(' - ({}, {})'.format(vertex.x, vertex.y))
84-
# [END vision_localize_objects_uri]
84+
# [END vision_localize_objects_gcs]
8585

8686

8787
# [START vision_handwritten_ocr]
@@ -130,7 +130,7 @@ def detect_handwritten_ocr(path):
130130
# [END vision_handwritten_ocr]
131131

132132

133-
# [START vision_handwritten_ocr_uri]
133+
# [START vision_handwritten_ocr_gcs]
134134
def detect_handwritten_ocr_uri(uri):
135135
"""Detects handwritten characters in the file located in Google Cloud
136136
Storage.
@@ -171,7 +171,7 @@ def detect_handwritten_ocr_uri(uri):
171171
for symbol in word.symbols:
172172
print('\tSymbol: {} (confidence: {})'.format(
173173
symbol.text, symbol.confidence))
174-
# [END vision_handwritten_ocr_uri]
174+
# [END vision_handwritten_ocr_gcs]
175175

176176

177177
if __name__ == '__main__':

0 commit comments

Comments
 (0)
0