@@ -38,31 +38,30 @@ Annotate a single image
3838
3939.. code-block :: python
4040
41+ >> > import io
4142 >> > from google.cloud import vision
4243 >> > client = vision.Client()
43- >> > image = client.image(' ./image.png' )
44+ >> > with io.open(' ./image.png' , ' rb' ) as image_file:
45+ >> > image = client.image(image_file.read())
4446 >> > faces = image.detect_faces(limit = 10 )
47+ >> > faces[0 ].landmarks.left_eye.position.x
48+ ... 1004.8003
4549
4650 Annotate multiple images
4751~~~~~~~~~~~~~~~~~~~~~~~~
4852
4953.. code-block :: python
5054
51- >> > first_image = client.image(' ./image.jpg' )
55+ >> > import io
56+ >> > from gcloud import vision
57+ >> > client = vision.Client()
58+ >> > with io.open(' ./image.png' , ' rb' ) as image_file:
59+ >> > first_image = client.image(image_file.read())
5260 >> > second_image = client.image(' gs://my-storage-bucket/image2.jpg' )
5361 >> > with client.batch():
5462 ... labels = first_image.detect_labels()
5563 ... faces = second_image.detect_faces(limit = 10 )
5664
57- or
58-
59- .. code-block :: python
60-
61- >> > images = []
62- >> > images.append(client.image(' ./image.jpg' ))
63- >> > images.append(client.image(' gs://my-storage-bucket/image2.jpg' ))
64- >> > faces = client.detect_faces_multi(images, limit = 10 )
65-
6665 No results returned
6766~~~~~~~~~~~~~~~~~~~
6867
@@ -86,9 +85,13 @@ You can call the detection method manually.
8685.. code-block :: python
8786
8887 >> > from google.cloud import vision
88+ >> > from gcloud.vision.image import Feature
89+ >> > from gcloud.vision.image import FeatureTypes
8990 >> > client = vision.Client()
9091 >> > image = client.image(' gs://my-test-bucket/image.jpg' )
91- >> > faces = image.detect(type = vision.FACE_DETECTION , limit = 10 )
92+ >> > features = [Feature(FeatureTypes.FACE_DETECTION , 5 ),
93+ Feature(FeatureTypes.LOGO_DETECTION , 3 )]
94+ >> > annotations = image.detect(features)
9295
9396 Face Detection
9497~~~~~~~~~~~~~~
@@ -102,11 +105,11 @@ see: https://cloud.google.com/vision/reference/rest/v1/images/annotate#type_1
102105
103106 >> > from google.cloud import vision
104107 >> > client = vision.Client()
105- >> > image = client.image(' . /image.jpg' )
108+ >> > image = client.image(' gs://my-test-bucket /image.jpg' )
106109 >> > faces = image.detect_faces(limit = 10 )
107- >> > faces[0 ].landmarks[ 0 ].type
110+ >> > faces[0 ].landmarks.left_eye.landmark_type
108111 ' LEFT_EYE'
109- >> > faces[0 ].landmarks[ 0 ] .position.x
112+ >> > faces[0 ].landmarks.left_eye .position.x
110113 1301.2404
111114 >> > faces[0 ].detection_confidence
112115 0.9863683
0 commit comments