Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Latest commit

 

History

History
195 lines (118 loc) · 7.26 KB

File metadata and controls

195 lines (118 loc) · 7.26 KB

Google Cloud Video Intelligence API Python Samples

image

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

Setup

Authentication

This sample requires you to have authentication setup. Refer to the Authentication Getting Started Guide for instructions on setting up credentials for applications.

Install Dependencies

  1. Clone python-docs-samples and change directory to the sample directory you want to use.

    $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
  2. Install pip and virtualenv if you do not already have them. You may want to refer to the Python Development Environment Setup Guide for Google Cloud Platform for instructions.

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

    $ virtualenv env
    $ source env/bin/activate
  4. Install the dependencies needed to run the samples.

    $ pip install -r requirements.txt

Samples

analyze

image

To run this sample:

$ python analyze.py

usage: analyze.py [-h]
                  {labels,labels_file,explicit_content,shots,transcribe,text_gcs,text_file,objects_gcs,objects_file}
                  ...

This application demonstrates label detection,
explicit content, and shot change detection using the Google Cloud API.

Usage Examples:

    python analyze.py labels gs://cloud-samples-data/video/chicago.mp4
    python analyze.py labels_file resources/cat.mp4
    python analyze.py shots gs://cloud-samples-data/video/gbikes_dinosaur.mp4
    python analyze.py explicit_content     gs://cloud-samples-data/video/gbikes_dinosaur.mp4
    python analyze.py text_gcs     gs://cloud-samples-data/video/googlework_tiny.mp4
    python analyze.py text_file resources/googlework_tiny.mp4
    python analyze.py objects_gcs gs://cloud-samples-data/video/cat.mp4
    python analyze.py objects_file resources/cat.mp4

positional arguments:
  {labels,labels_file,explicit_content,shots,transcribe,text_gcs,text_file,objects_gcs,objects_file}
    labels              Detects labels given a GCS path.
    labels_file         Detect labels given a file path.
    explicit_content    Detects explicit content from the GCS path to a video.
    shots               Detects camera shot changes.
    transcribe          Transcribe speech from a video stored on GCS.
    text_gcs            Detect text in a video stored on GCS.
    text_file           Detect text in a local video.
    objects_gcs         Object tracking in a video stored on GCS.
    objects_file        Object tracking in a local video.

optional arguments:
  -h, --help            show this help message and exit

beta samples

image

To run this sample:

$ python beta_snippets.py

usage: beta_snippets.py [-h]
                        {transcription,video-text-gcs,video-text,track-objects-gcs,track-objects,streaming-labels,streaming-shot-change,streaming-objects,streaming-explicit-content,streaming-annotation-storage,streaming-automl-classification}
                        ...

This application demonstrates speech transcription using the
Google Cloud API.

Usage Examples:
    python beta_snippets.py transcription         gs://python-docs-samples-tests/video/googlework_tiny.mp4

    python beta_snippets.py video-text-gcs         gs://python-docs-samples-tests/video/googlework_tiny.mp4

    python beta_snippets.py track-objects resources/cat.mp4

    python beta_snippets.py streaming-labels resources/cat.mp4

    python beta_snippets.py streaming-shot-change resources/cat.mp4

    python beta_snippets.py streaming-objects resources/cat.mp4

    python beta_snippets.py streaming-explicit-content resources/cat.mp4

    python beta_snippets.py streaming-annotation-storage resources/cat.mp4     gs://mybucket/myfolder

    python beta_snippets.py streaming-automl-classification resources/cat.mp4     $PROJECT_ID $MODEL_ID

positional arguments:
  {transcription,video-text-gcs,video-text,track-objects-gcs,track-objects,streaming-labels,streaming-shot-change,streaming-objects,streaming-explicit-content,streaming-annotation-storage,streaming-automl-classification}
    transcription       Transcribe speech from a video stored on GCS.
    video-text-gcs      Detect text in a video stored on GCS.
    video-text          Detect text in a local video.
    track-objects-gcs   Object Tracking.
    track-objects       Object Tracking.
    streaming-labels
    streaming-shot-change
    streaming-objects
    streaming-explicit-content
    streaming-annotation-storage
    streaming-automl-classification

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.