viam.media.video
Module Contents
Classes
DEPRECATED Use |
|
str(object='') -> str |
|
A native implementation of an image. |
|
An implementation of ViamImage that contains a name attribute. |
Attributes
- viam.media.video.LAZY_SUFFIX = '+lazy'
- viam.media.video.LIBRARY_SUPPORTED_FORMATS
- class viam.media.video.RawImage[source]
Bases:
NamedTuple
DEPRECATED Use
ViamImage
insteadA raw bytes representation of an image.
A RawImage should be returned instead of a PIL Image instance under one of the following conditions
The requested mime type has the LAZY_SUFFIX string appended to it
2) The requested mime type is not supported for decoding/encoding by Viam’s Python SDK
- data: bytes
The raw data of the image
- mime_type: str
The mimetype of the image
- bytes_to_depth_array() List[List[int]] [source]
Decode the data of an image that has the custom depth MIME type
image/vnd.viam.dep
into a standard representation.- Raises:
NotSupportedError – Raised if given an image that is not of MIME type image/vnd.viam.dep.
- Returns:
The standard representation of the image.
- Return type:
List[List[int]]
- class viam.media.video.CameraMimeType[source]
Bases:
str
,enum.Enum
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- property with_lazy_suffix: str
- VIAM_RGBA = 'image/vnd.viam.rgba'
- VIAM_RAW_DEPTH = 'image/vnd.viam.dep'
- JPEG = 'image/jpeg'
- PNG = 'image/png'
- PCD = 'pointcloud/pcd'
- UNSUPPORTED = 'unsupported'
- classmethod is_supported(mime_type: str) bool [source]
Check if the provided mime_type is supported.
- Parameters:
mime_type (str) – The mime_type to check
- Returns:
Whether the mime_type is supported
- Return type:
bool
- classmethod from_proto(format: viam.proto.component.camera.Format.ValueType) CameraMimeType [source]
Returns the mimetype from a proto enum.
- Parameters:
format (Format.ValueType) – The mimetype in a proto enum.
- Returns:
The mimetype.
- Return type:
Self
- class viam.media.video.ViamImage(data: bytes, mime_type: CameraMimeType)[source]
A native implementation of an image.
Provides the raw data and the mime type, as well as lazily loading and caching the PIL.Image representation.
- property data: bytes
The raw bytes of the image
- property mime_type: CameraMimeType
The mime type of the image
- property image: PIL.Image.Image | None
The PIL.Image representation of the image. If the mime type is not supported, this will be None.
- bytes_to_depth_array() List[List[int]] [source]
Decode the data of an image that has the custom depth MIME type
image/vnd.viam.dep
into a standard representation.- Raises:
NotSupportedError – Raised if given an image that is not of MIME type image/vnd.viam.dep.
- Returns:
The standard representation of the image.
- Return type:
List[List[int]]