viam.media.utils.pil ==================== .. py:module:: viam.media.utils.pil Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/viam/media/utils/pil/viam_rgba_plugin/index Attributes ---------- .. autoapisummary:: viam.media.utils.pil.RGBA_FORMAT_LABEL viam.media.utils.pil.LIBRARY_SUPPORTED_FORMATS Classes ------- .. autoapisummary:: viam.media.utils.pil.CameraMimeType viam.media.utils.pil.ViamImage Functions --------- .. autoapisummary:: viam.media.utils.pil.viam_to_pil_image viam.media.utils.pil.pil_to_viam_image Package Contents ---------------- .. py:class:: CameraMimeType Bases: :py:obj:`str`, :py:obj:`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'. .. py:attribute:: VIAM_RGBA :value: 'image/vnd.viam.rgba' .. py:attribute:: VIAM_RAW_DEPTH :value: 'image/vnd.viam.dep' .. py:attribute:: JPEG :value: 'image/jpeg' .. py:attribute:: PNG :value: 'image/png' .. py:attribute:: PCD :value: 'pointcloud/pcd' .. py:method:: from_string(value: str) -> typing_extensions.Self :classmethod: Return the mimetype from a string. :param value: The mimetype as a string :type value: str :returns: The mimetype :rtype: Self .. py:method:: from_proto(format: viam.proto.component.camera.Format.ValueType) -> CameraMimeType :classmethod: Returns the mimetype from a proto enum. :param format: The mimetype in a proto enum. :type format: Format.ValueType :returns: The mimetype. :rtype: Self .. py:method:: to_proto() -> viam.proto.component.camera.Format.ValueType Returns the mimetype in a proto enum. :returns: The mimetype in a proto enum. :rtype: Format.ValueType .. py:class:: ViamImage(data: bytes, mime_type: CameraMimeType) A native implementation of an image. Provides the raw data and the mime type. .. py:property:: data :type: bytes The raw bytes of the image .. py:property:: mime_type :type: CameraMimeType The mime type of the image .. py:property:: width :type: Optional[int] The width of the image .. py:property:: height :type: Optional[int] The height of the image .. py:method:: bytes_to_depth_array() -> List[List[int]] 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 the image is not of MIME type `image/vnd.viam.dep`. :returns: The standard representation of the image. :rtype: List[List[int]] .. py:data:: RGBA_FORMAT_LABEL :value: 'VIAM_RGBA' .. py:data:: LIBRARY_SUPPORTED_FORMATS .. py:function:: viam_to_pil_image(image: viam.media.video.ViamImage) -> PIL.Image.Image Convert a ViamImage to a PIL.Image. In order to use this function, Pillow must be installed. https://pillow.readthedocs.io/ :param image: The image to convert. :type image: ViamImage :returns: The resulting PIL.Image :rtype: Image.Image .. py:function:: pil_to_viam_image(image: PIL.Image.Image, mime_type: viam.media.video.CameraMimeType) -> viam.media.video.ViamImage Convert a PIL.Image to a ViamImage. In order to use this function, Pillow must be installed. https://pillow.readthedocs.io/ :param image: The image to convert. :type image: Image.Image :param mime_type: The mime type to convert the image to. :type mime_type: CameraMimeType :returns: The resulting ViamImage :rtype: ViamImage