Vision Client#

Client#

Client for interacting with the Google Cloud Vision API.

class google.cloud.vision.client.Client(project=None, credentials=None, http=None)[source]#

Bases: google.cloud.client.JSONClient

Client to bundle configuration needed for API requests.

Parameters:
  • project (str) – the project which the client acts on behalf of. If not passed, falls back to the default inferred from the environment.
  • credentials (oauth2client.client.OAuth2Credentials or NoneType) – The OAuth2 Credentials to use for the connection owned by this client. If not passed (and if no http object is passed), falls back to the default inferred from the environment.
  • http (httplib2.Http or class that defines request().) – An optional HTTP object to make requests. If not passed, an http object is created that is bound to the credentials for the current object.
annotate(image, features)[source]#

Annotate an image to discover it’s attributes.

Parameters:
Return type:

dict

Returns:

List of annotations.

class google.cloud.vision.client.VisionRequest(image, features)[source]#

Bases: object

Request container with image and features information to annotate.

Parameters:
  • features (list of gcoud.vision.feature.Feature.) – The features that dictate which annotations to run.
  • image (bytes) – Either Google Cloud Storage URI or raw byte stream of image.
as_dict()[source]#

Dictionary representation of Image.

features#

List of Feature objects.

image#

Image object containing image content.

Connection#

Create / interact with Google Cloud Vision connections.

class google.cloud.vision.connection.Connection(credentials=None, http=None)[source]#

Bases: google.cloud.connection.JSONConnection

A connection to Google Cloud Vision via the JSON REST API.

Parameters:
API_BASE_URL = 'https://vision.googleapis.com'#

The base of the API call URL.

API_URL_TEMPLATE = '{api_base_url}/{api_version}{path}'#

A template for the URL of a particular API call.

API_VERSION = 'v1'#

The version of the API, used in building the API call’s URL.

SCOPE = ('https://www.googleapis.com/auth/cloud-platform',)#

The scopes required for authenticating as a Cloud Vision consumer.