:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/CameraFeed.xml. .. _class_CameraFeed: CameraFeed ========== **Inherits:** :ref:`RefCounted` **<** :ref:`Object` A camera feed gives you access to a single physical camera attached to your device. .. rst-class:: classref-introduction-group Description ----------- A camera feed gives you access to a single physical camera attached to your device. When enabled, Godot will start capturing frames from the camera which can then be used. See also :ref:`CameraServer`. \ **Note:** Many cameras will return YCbCr images which are split into two textures and need to be combined in a shader. Godot does this automatically for you if you set the environment to show the camera image in the background. \ **Note:** This class is currently only implemented on Linux, Android, macOS, and iOS. On other platforms no **CameraFeed**\ s will be available. To get a **CameraFeed** on iOS, the camera plugin from `godot-ios-plugins `__ is required. .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +---------------------------------------+-----------------------------------------------------------------+------------------------------------+ | :ref:`bool` | :ref:`feed_is_active` | ``false`` | +---------------------------------------+-----------------------------------------------------------------+------------------------------------+ | :ref:`Transform2D` | :ref:`feed_transform` | ``Transform2D(1, 0, 0, -1, 0, 1)`` | +---------------------------------------+-----------------------------------------------------------------+------------------------------------+ | :ref:`Array` | :ref:`formats` | ``[]`` | +---------------------------------------+-----------------------------------------------------------------+------------------------------------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`_activate_feed`\ (\ ) |virtual| | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_deactivate_feed`\ (\ ) |virtual| | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`FeedDataType` | :ref:`get_datatype`\ (\ ) |const| | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_id`\ (\ ) |const| | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_name`\ (\ ) |const| | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`FeedPosition` | :ref:`get_position`\ (\ ) |const| | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_texture_tex_id`\ (\ feed_image_type\: :ref:`FeedImage`\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_external`\ (\ width\: :ref:`int`, height\: :ref:`int`\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`set_format`\ (\ index\: :ref:`int`, parameters\: :ref:`Dictionary`\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_name`\ (\ name\: :ref:`String`\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_position`\ (\ position\: :ref:`FeedPosition`\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_rgb_image`\ (\ rgb_image\: :ref:`Image`\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_ycbcr_image`\ (\ ycbcr_image\: :ref:`Image`\ ) | +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Signals ------- .. _class_CameraFeed_signal_format_changed: .. rst-class:: classref-signal **format_changed**\ (\ ) :ref:`🔗` Emitted when the format has changed. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_signal_frame_changed: .. rst-class:: classref-signal **frame_changed**\ (\ ) :ref:`🔗` Emitted when a new frame is available. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Enumerations ------------ .. _enum_CameraFeed_FeedDataType: .. rst-class:: classref-enumeration enum **FeedDataType**: :ref:`🔗` .. _class_CameraFeed_constant_FEED_NOIMAGE: .. rst-class:: classref-enumeration-constant :ref:`FeedDataType` **FEED_NOIMAGE** = ``0`` No image set for the feed. .. _class_CameraFeed_constant_FEED_RGB: .. rst-class:: classref-enumeration-constant :ref:`FeedDataType` **FEED_RGB** = ``1`` Feed supplies RGB images. .. _class_CameraFeed_constant_FEED_YCBCR: .. rst-class:: classref-enumeration-constant :ref:`FeedDataType` **FEED_YCBCR** = ``2`` Feed supplies YCbCr images that need to be converted to RGB. .. _class_CameraFeed_constant_FEED_YCBCR_SEP: .. rst-class:: classref-enumeration-constant :ref:`FeedDataType` **FEED_YCBCR_SEP** = ``3`` Feed supplies separate Y and CbCr images that need to be combined and converted to RGB. .. _class_CameraFeed_constant_FEED_EXTERNAL: .. rst-class:: classref-enumeration-constant :ref:`FeedDataType` **FEED_EXTERNAL** = ``4`` Feed supplies external image. .. rst-class:: classref-item-separator ---- .. _enum_CameraFeed_FeedPosition: .. rst-class:: classref-enumeration enum **FeedPosition**: :ref:`🔗` .. _class_CameraFeed_constant_FEED_UNSPECIFIED: .. rst-class:: classref-enumeration-constant :ref:`FeedPosition` **FEED_UNSPECIFIED** = ``0`` Unspecified position. .. _class_CameraFeed_constant_FEED_FRONT: .. rst-class:: classref-enumeration-constant :ref:`FeedPosition` **FEED_FRONT** = ``1`` Camera is mounted at the front of the device. .. _class_CameraFeed_constant_FEED_BACK: .. rst-class:: classref-enumeration-constant :ref:`FeedPosition` **FEED_BACK** = ``2`` Camera is mounted at the back of the device. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_CameraFeed_property_feed_is_active: .. rst-class:: classref-property :ref:`bool` **feed_is_active** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_active**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_active**\ (\ ) If ``true``, the feed is active. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_property_feed_transform: .. rst-class:: classref-property :ref:`Transform2D` **feed_transform** = ``Transform2D(1, 0, 0, -1, 0, 1)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_transform**\ (\ value\: :ref:`Transform2D`\ ) - :ref:`Transform2D` **get_transform**\ (\ ) The transform applied to the camera's image. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_property_formats: .. rst-class:: classref-property :ref:`Array` **formats** = ``[]`` :ref:`🔗` .. rst-class:: classref-property-setget - :ref:`Array` **get_formats**\ (\ ) Formats supported by the feed. Each entry is a :ref:`Dictionary` describing format parameters. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_CameraFeed_private_method__activate_feed: .. rst-class:: classref-method :ref:`bool` **_activate_feed**\ (\ ) |virtual| :ref:`🔗` Called when the camera feed is activated. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_private_method__deactivate_feed: .. rst-class:: classref-method |void| **_deactivate_feed**\ (\ ) |virtual| :ref:`🔗` Called when the camera feed is deactivated. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_method_get_datatype: .. rst-class:: classref-method :ref:`FeedDataType` **get_datatype**\ (\ ) |const| :ref:`🔗` Returns feed image data type. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_method_get_id: .. rst-class:: classref-method :ref:`int` **get_id**\ (\ ) |const| :ref:`🔗` Returns the unique ID for this feed. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_method_get_name: .. rst-class:: classref-method :ref:`String` **get_name**\ (\ ) |const| :ref:`🔗` Returns the camera's name. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_method_get_position: .. rst-class:: classref-method :ref:`FeedPosition` **get_position**\ (\ ) |const| :ref:`🔗` Returns the position of camera on the device. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_method_get_texture_tex_id: .. rst-class:: classref-method :ref:`int` **get_texture_tex_id**\ (\ feed_image_type\: :ref:`FeedImage`\ ) :ref:`🔗` Returns the texture backend ID (usable by some external libraries that need a handle to a texture to write data). .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_method_set_external: .. rst-class:: classref-method |void| **set_external**\ (\ width\: :ref:`int`, height\: :ref:`int`\ ) :ref:`🔗` Sets the feed as external feed provided by another library. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_method_set_format: .. rst-class:: classref-method :ref:`bool` **set_format**\ (\ index\: :ref:`int`, parameters\: :ref:`Dictionary`\ ) :ref:`🔗` Sets the feed format parameters for the given ``index`` in the :ref:`formats` array. Returns ``true`` on success. By default, the YUYV encoded stream is transformed to :ref:`FEED_RGB`. The YUYV encoded stream output format can be changed by setting ``parameters``'s ``output`` entry to one of the following: - ``"separate"`` will result in :ref:`FEED_YCBCR_SEP`; - ``"grayscale"`` will result in desaturated :ref:`FEED_RGB`; - ``"copy"`` will result in :ref:`FEED_YCBCR`. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_method_set_name: .. rst-class:: classref-method |void| **set_name**\ (\ name\: :ref:`String`\ ) :ref:`🔗` Sets the camera's name. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_method_set_position: .. rst-class:: classref-method |void| **set_position**\ (\ position\: :ref:`FeedPosition`\ ) :ref:`🔗` Sets the position of this camera. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_method_set_rgb_image: .. rst-class:: classref-method |void| **set_rgb_image**\ (\ rgb_image\: :ref:`Image`\ ) :ref:`🔗` Sets RGB image for this feed. .. rst-class:: classref-item-separator ---- .. _class_CameraFeed_method_set_ycbcr_image: .. rst-class:: classref-method |void| **set_ycbcr_image**\ (\ ycbcr_image\: :ref:`Image`\ ) :ref:`🔗` Sets YCbCr image for this feed. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`