Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates GCS snippet to match local file #836

Merged
merged 2 commits into from
Feb 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 17 additions & 22 deletions vision/cloud-client/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
Google Cloud Vision API Python Samples
===============================================================================

This directory contains samples for Google Cloud Vision API. `Google Cloud Vision API`_ allows developers to easily integrate vision detection features within applications, including image labeling, face and landmark detection, optical character recognition (OCR), and tagging of explicit content
This directory contains samples for Google Cloud Vision API. [Google Cloud Vision API][0] allows developers to easily integrate vision detection features within applications, including image labeling, face and landmark detection, optical character recognition (OCR), and tagging of explicit content




.. _Google Cloud Vision API: https://cloud.google.com/vision/docs
[0]: https://cloud.google.com/vision/docs

Setup
-------------------------------------------------------------------------------
Expand All @@ -17,12 +17,12 @@ Setup
Authentication
++++++++++++++

Authentication is typically done through `Application Default Credentials`_,
Authentication is typically done through [Application Default Credentials][11],
which means you do not have to change the code to authenticate as long as
your environment has credentials. You have a few options for setting up
authentication:

#. When running locally, use the `Google Cloud SDK`_
#. When running locally, use the [Google Cloud SDK][12]

.. code-block:: bash

Expand All @@ -31,7 +31,7 @@ authentication:

#. When running on App Engine or Compute Engine, credentials are already
set-up. However, you may need to configure your Compute Engine instance
with `additional scopes`_.
with [additional scopes][13].

#. You can create a `Service Account key file`_. This file can be used to
authenticate to Google Cloud Platform services from any environment. To use
Expand All @@ -42,14 +42,14 @@ authentication:

export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json

.. _Application Default Credentials: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow
.. _additional scopes: https://cloud.google.com/compute/docs/authentication#using
.. _Service Account key file: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount
[11]: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow
[12]: https://cloud.google.com/compute/docs/authentication#using
[13]: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount

Install Dependencies
++++++++++++++++++++

#. Install `pip`_ and `virtualenv`_ if you do not already have them.
#. Install [pip][21] and [virtualenv][22] if you do not already have them.

#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.

Expand All @@ -64,8 +64,8 @@ Install Dependencies

$ pip install -r requirements.txt

.. _pip: https://pip.pypa.io/
.. _virtualenv: https://virtualenv.pypa.io/
[21]: https://pip.pypa.io/
[22]: https://virtualenv.pypa.io/

Samples
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -152,16 +152,11 @@ To run this sample:
The client library
-------------------------------------------------------------------------------

This sample uses the `Google Cloud Client Library for Python`_.
This sample uses the [Google Cloud Client Library for Python][1].
You can read the documentation for more details on API usage and use GitHub
to `browse the source`_ and `report issues`_.
to [browse the source][2] and [report issues][3].

.. Google Cloud Client Library for Python:
https://googlecloudplatform.github.io/google-cloud-python/
.. browse the source:
https://github.com/GoogleCloudPlatform/google-cloud-python
.. report issues:
https://github.com/GoogleCloudPlatform/google-cloud-python/issues


.. _Google Cloud SDK: https://cloud.google.com/sdk/
[1]: https://googlecloudplatform.github.io/google-cloud-python/
[2]: https://github.com/GoogleCloudPlatform/google-cloud-python
[3]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues
[4]: https://cloud.google.com/sdk/
14 changes: 14 additions & 0 deletions vision/cloud-client/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,20 @@ def detect_fulltext_uri(uri):
image = vision_client.image(source_uri=uri)

fulltext = image.detect_full_text()

for b, page in enumerate(fulltext.pages):
print(page.width)
for bb, block in enumerate(page.blocks):
print('Block: {}'.format(block.bounding_box))
print('Type: {}'.format(dir(block)))
print('Type: {}'.format(block.block_type))
for p, paragraph in enumerate(block.paragraphs):
print('\tParagraph: ({})'.format(paragraph.bounding_box))
print('\twords: ({})'.format((paragraph.words)))
for w, word in enumerate(paragraph.words):
for s, symbol in enumerate(word.symbols):
print('\t\t\t$:{}'.format(symbol.text))

print(fulltext.text)


Expand Down