Skip to content

Commit

Permalink
Adds new examples, replaces markdown with restructured text [(#945)](G…
Browse files Browse the repository at this point in the history
…oogleCloudPlatform/python-docs-samples#945)

* Adds new examples, replaces markdown with restructured text

* Address review feedback

* Use videos from pubilc bucket, update to new client library.

* Style nit
  • Loading branch information
gguuss authored and Jon Wayne Parrott committed May 18, 2017
1 parent 7568089 commit f06b643
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 53 deletions.
32 changes: 0 additions & 32 deletions samples/analyze/README.md

This file was deleted.

126 changes: 126 additions & 0 deletions samples/analyze/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
.. This file is automatically generated. Do not edit this file directly.
Google Cloud Video Intelligence API Python Samples
===============================================================================

This directory contains samples for Google Cloud Video Intelligence API. `Google Cloud Video Intelligence API`_ allows developers to easily integrate feature detection in video.




.. _Google Cloud Video Intelligence API: https://cloud.google.com/video-intelligence/docs

Setup
-------------------------------------------------------------------------------


Authentication
++++++++++++++

Authentication is typically done through `Application Default Credentials`_,
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`_

.. code-block:: bash
gcloud auth application-default login
#. 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`_.

#. 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
the file, set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to
the path to the key file, for example:

.. code-block:: bash
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

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

#. Install `pip`_ and `virtualenv`_ if you do not already have them.

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

.. code-block:: bash
$ virtualenv env
$ source env/bin/activate
#. Install the dependencies needed to run the samples.

.. code-block:: bash
$ pip install -r requirements.txt
.. _pip: https://pip.pypa.io/
.. _virtualenv: https://virtualenv.pypa.io/

Samples
-------------------------------------------------------------------------------

analyze
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



To run this sample:

.. code-block:: bash
$ python analyze.py
usage: analyze.py [-h] {faces,labels,labels_file,safe_search,shots} ...
This application demonstrates face detection, label detection, safe search,
and shot change detection using the Google Cloud API.
Usage Examples:
python analyze.py faces gs://cloudmleap/video/next/volleyball_court.mp4
python analyze.py labels gs://cloudmleap/video/next/fox-snatched.mp4
python analyze.py labels_file resources/fox-snatched.mp4
python analyze.py shots gs://cloudmleap/video/next/gbikes_dinosaur.mp4
python analyze.py safe_search gs://cloudmleap/video/next/animals.mp4
positional arguments:
{faces,labels,labels_file,safe_search,shots}
faces Detects faces given a GCS path.
labels Detects labels given a GCS path.
labels_file Detects labels given a file path.
safe_search Detects safe search features the GCS path to a video.
shots Detects camera shot changes.
optional arguments:
-h, --help show this help message and exit
The client library
-------------------------------------------------------------------------------

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

.. 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/
20 changes: 20 additions & 0 deletions samples/analyze/README.rst.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file is used to generate README.rst

product:
name: Google Cloud Video Intelligence API
short_name: Cloud Video Intelligence API
url: https://cloud.google.com/video-intelligence/docs
description: >
`Google Cloud Video Intelligence API`_ allows developers to easily
integrate feature detection in video.

setup:
- auth
- install_deps

samples:
- name: analyze
file: analyze.py
show_help: True

cloud_client_library: true
Loading

0 comments on commit f06b643

Please sign in to comment.