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` The compatible mime-types for cameras and vision services. You can use the `CameraMimeType.CUSTOM(...)` method to use an unlisted mime-type. .. py:attribute:: VIAM_RGBA :type: typing_extensions.ClassVar[typing_extensions.Self] .. py:attribute:: VIAM_RAW_DEPTH :type: typing_extensions.ClassVar[typing_extensions.Self] .. py:attribute:: JPEG :type: typing_extensions.ClassVar[typing_extensions.Self] .. py:attribute:: PNG :type: typing_extensions.ClassVar[typing_extensions.Self] .. py:attribute:: PCD :type: typing_extensions.ClassVar[typing_extensions.Self] .. py:property:: name :type: str .. py:property:: value :type: str .. py:method:: CUSTOM(mime_type: str) -> typing_extensions.Self :classmethod: Create a custom mime type. :param mime_type: The mimetype as a string :type mime_type: str .. 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) -> typing_extensions.Self :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:property:: proto :type: viam.proto.component.camera.Format.ValueType Returns the mimetype in a proto enum. :returns: The mimetype in a proto enum. :rtype: Format.ValueType .. py:method:: to_proto() -> viam.proto.component.camera.Format.ValueType DEPRECATED: Use `CameraMimeType.proto` .. 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