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.JSONClientClient 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.OAuth2CredentialsorNoneType) – The OAuth2 Credentials to use for the connection owned by this client. If not passed (and if nohttpobject is passed), falls back to the default inferred from the environment. - http (
httplib2.Httpor class that definesrequest().) – An optional HTTP object to make requests. If not passed, anhttpobject is created that is bound to thecredentialsfor the current object.
-
annotate(image, features)[source]# Annotate an image to discover it’s attributes.
Parameters: - image (str) – A string which can be a URL, a Google Cloud Storage path, or a byte stream of the image.
- features (list of
google.cloud.vision.feature.Feature) –The type of detection that the Vision API should use to determine image attributes. Pricing is based on the number of Feature Types.
Return type: Returns: List of annotations.
-
class
google.cloud.vision.client.VisionRequest(image, features)[source]# Bases:
objectRequest 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.
-
features# List of Feature objects.
-
image# Image object containing image content.
- features (list of
Connection#
Create / interact with Google Cloud Vision connections.
-
class
google.cloud.vision.connection.Connection(credentials=None, http=None)[source]# Bases:
google.cloud.connection.JSONConnectionA connection to Google Cloud Vision via the JSON REST API.
Parameters: - credentials (
oauth2client.client.OAuth2Credentials) – (Optional) The OAuth2 Credentials to use for this connection. - http (
httplib2.Httpor class that definesrequest().) – (Optional) HTTP object to make requests. - api_base_url (string) – The base of the API call URL. Defaults to the value
Connection.API_BASE_URL.
-
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.
- credentials (