Vision Image#

Image#

Image represented by either a URI or byte stream.

class google.cloud.vision.image.Image(client, content=None, source_uri=None)[source]#

Bases: object

Image representation containing information to be annotate.

Parameters:
  • content (bytes) – Byte stream of an image.
  • source_uri (str) – Google Cloud Storage URI of image.
  • client (Client) – Instance of Vision client.
as_dict()[source]#

Generate dictionary structure for request.

Return type:dict
Returns:Dictionary with source information for image.
content#

Base64 encoded image content.

Return type:str
Returns:Base64 encoded image bytes.
detect_faces(limit=10)[source]#

Detect faces in image.

Parameters:limit (int) – The number of faces to try and detect.
Return type:list
Returns:List of Face.
detect_labels(limit=10)[source]#

Detect labels that describe objects in an image.

Parameters:limit (int) – The maximum number of labels to try and detect.
Return type:list
Returns:List of EntityAnnotation
detect_landmarks(limit=10)[source]#

Detect landmarks in an image.

Parameters:limit (int) – The maximum number of landmarks to find.
Return type:list
Returns:List of EntityAnnotation.
detect_logos(limit=10)[source]#

Detect logos in an image.

Parameters:limit (int) – The maximum number of logos to find.
Return type:list
Returns:List of EntityAnnotation.
detect_properties(limit=10)[source]#

Detect the color properties of an image.

Parameters:limit (int) – The maximum number of image properties to find.
Return type:list
Returns:List of ImagePropertiesAnnotation.

Retreive safe search properties from an image.

Parameters:limit (int) – The number of faces to try and detect.
Return type:list
Returns:List of SafeSearchAnnotation.
detect_text(limit=10)[source]#

Detect text in an image.

Parameters:limit (int) – The maximum instances of text to find.
Return type:list
Returns:List of EntityAnnotation.
source#

Google Cloud Storage URI.

Return type:str
Returns:String of Google Cloud Storage URI.

Geometry#

Geometry and other generic classes used by the Vision API.

class google.cloud.vision.geometry.Bounds(vertices)[source]#

Bases: google.cloud.vision.geometry.BoundsBase

A polygon boundry of the detected feature.

class google.cloud.vision.geometry.BoundsBase(vertices)[source]#

Bases: object

Base class for handling bounds with vertices.

Parameters:vertices (list of Vertex) – List of vertcies describing points on an image.
classmethod from_api_repr(response_vertices)[source]#

Factory: construct BoundsBase instance from Vision API response.

Parameters:response_vertices (dict) – List of vertices.
Return type:BoundsBase or None
Returns:Instance of BoundsBase with populated verticies or None.
vertices#

List of vertices.

Return type:list of Vertex
Returns:List of populated vertices.
class google.cloud.vision.geometry.FDBounds(vertices)[source]#

Bases: google.cloud.vision.geometry.BoundsBase

The bounding polygon of just the skin portion of the face.

class google.cloud.vision.geometry.LocationInformation(latitude, longitude)[source]#

Bases: object

Representation of location information returned by the Vision API.

Parameters:
  • latitude (float) – Latitude coordinate of geographical location.
  • longitude (float) – Longitude coordinate of geographical location.
classmethod from_api_repr(response)[source]#

Factory: construct location information from Vision API response.

Parameters:response (dict) – Dictionary response of locations.
Return type:LocationInformation
Returns:LocationInformation with populated latitude and longitude.
latitude#

Latitude coordinate.

Return type:float
Returns:Latitude coordinate of location.
longitude#

Longitude coordinate.

Return type:float
Returns:Longitude coordinate of location.
class google.cloud.vision.geometry.Position(x_coordinate, y_coordinate, z_coordinate)[source]#

Bases: object

A 3D position in the image.

See: https://cloud.google.com/vision/reference/rest/v1/images/annotate#Position

Parameters:
  • x_coordinate (float) – X position coordinate.
  • y_coordinate (float) – Y position coordinate.
  • z_coordinate (float) – Z position coordinate.
classmethod from_api_repr(response_position)[source]#

Factory: construct 3D position from API response.

Return type:Position
Returns:Position constructed with 3D points from API response.
x_coordinate#

X position coordinate.

Return type:float
Returns:X position coordinate.
y_coordinate#

Y position coordinate.

Return type:float
Returns:Y position coordinate.
z_coordinate#

Z position coordinate.

Return type:float
Returns:Z position coordinate.
class google.cloud.vision.geometry.Vertex(x_coordinate, y_coordinate)[source]#

Bases: object

A vertex represents a 2D point in the image.

See: https://cloud.google.com/vision/reference/rest/v1/images/annotate#Vertex

Parameters:
  • x_coordinate (float) – X position coordinate.
  • y_coordinate (float) – Y position coordinate.
x_coordinate#

X position coordinate.

Return type:float
Returns:X position coordinate.
y_coordinate#

Y position coordinate.

Return type:float
Returns:Y position coordinate.

Likelihood#

Likelihood constants returned from Vision API.

class google.cloud.vision.likelihood.Likelihood[source]#

Bases: object

A representation of likelihood to give stable results across upgrades.

See: https://cloud.google.com/vision/reference/rest/v1/images/annotate#likelihood

LIKELY = 'LIKELY'#
POSSIBLE = 'POSSIBLE'#
UNKNOWN = 'UNKNOWN'#
UNLIKELY = 'UNLIKELY'#
VERY_LIKELY = 'VERY_LIKELY'#
VERY_UNLIKELY = 'VERY_UNLIKELY'#