1+ ####################
12Using the Vision API
2- ====================
3+ ####################
34
5+
6+ ********************************
47Authentication and Configuration
5- --------------------------------
8+ ********************************
69
710- For an overview of authentication in ``google-cloud-python ``,
811 see :doc: `google-cloud-auth `.
@@ -31,8 +34,43 @@ or pass in ``credentials`` and ``project`` explicitly.
3134 >> > client = vision.Client(project = ' my-project' , credentials = creds)
3235
3336
37+ *****************************************************
38+ Creating an :class: `~google.cloud.vision.image.Image `
39+ *****************************************************
40+
41+ The :class: `~google.cloud.vision.image.Image ` class is used to load image
42+ data from sources such as a Google Cloud Storage URI, raw bytes, or a file.
43+
44+
45+ From a Google Cloud Storage URI
46+ ===============================
47+
48+ .. code-block :: python
49+
50+ >> > from google.cloud import vision
51+ >> > client = vision.Client()
52+ >> > image = client.image(source_uri = ' gs://my-test-bucket/image.jpg' )
53+
54+
55+ From a filename
56+ ===============
57+
58+ .. code-block :: python
59+
60+ >> > image = client.image(filename = ' image.jpg' )
61+
62+ From raw bytes
63+ ==============
64+
65+ .. code-block :: python
66+
67+ >> > with open (' ./image.jpg' , ' rb' ) as image_file:
68+ ... bytes_image = client.image(content = image_file.read())
69+
70+
71+ ****************
3472Manual Detection
35- ~~~~~~~~~~~~~~~~
73+ ****************
3674
3775You can call the detection method manually.
3876
@@ -60,8 +98,9 @@ You can call the detection method manually.
6098 ' github'
6199
62100
101+ **************
63102Face Detection
64- ~~~~~~~~~~~~~~
103+ **************
65104
66105:meth: `~google.cloud.vision.image.Image.detect_faces ` will search for faces in
67106an image and return the coordinates in the image of each `landmark type `_ that
@@ -87,8 +126,9 @@ was detected.
87126 0.02545464
88127
89128
129+ ***************
90130Label Detection
91- ~~~~~~~~~~~~~~~
131+ ***************
92132
93133:meth: `~google.cloud.vision.image.Image.detect_labels ` will attempt to label
94134objects in an image. If there is a car, person and a dog in the image, label
@@ -107,8 +147,9 @@ certainty from ``0.0 to 1.0``.
107147 0.9863683
108148
109149
150+ ******************
110151Landmark Detection
111- ~~~~~~~~~~~~~~~~~~
152+ ******************
112153
113154:meth: `~google.cloud.vision.image.Image.detect_landmarks ` will attempt to
114155detect landmarks such as "Mount Rushmore" and the "Sydney Opera House". The API
@@ -133,8 +174,9 @@ will also provide their known geographical locations if available.
133174 162
134175
135176
177+ **************
136178Logo Detection
137- ~~~~~~~~~~~~~~
179+ **************
138180
139181With :meth: `~google.cloud.vision.image.Image.detect_logos `, you can identify
140182brand logos in an image. Their shape and location in the image can be found by
@@ -162,8 +204,9 @@ iterating through the detected logo's ``vertices``.
162204 62
163205
164206
207+ *********************
165208Safe Search Detection
166- ~~~~~~~~~~~~~~~~~~~~~
209+ *********************
167210
168211:meth: `~google.cloud.vision.image.Image.detect_safe_search ` will try to
169212categorize the entire contents of the image under four categories.
@@ -192,8 +235,9 @@ categorize the entire contents of the image under four categories.
192235 ' LIKELY'
193236
194237
238+ **************
195239Text Detection
196- ~~~~~~~~~~~~~~
240+ **************
197241
198242:meth: `~google.cloud.vision.image.Image.detect_text ` performs OCR to find text
199243in an image.
@@ -213,8 +257,9 @@ in an image.
213257 ' some other text in the image'
214258
215259
260+ ****************
216261Image Properties
217- ~~~~~~~~~~~~~~~~
262+ ****************
218263
219264:meth: `~google.cloud.vision.image.Image.detect_properties ` will process the
220265image and determine the dominant colors in the image.
@@ -238,8 +283,9 @@ image and determine the dominant colors in the image.
238283 0.758658
239284
240285
286+ ****************
241287No results found
242- ~~~~~~~~~~~~~~~~
288+ ****************
243289
244290If no results for the detection performed can be extracted from the image, then
245291an empty list is returned. This behavior is similiar with all detection types.
0 commit comments