Index · Object → RefCounted → CameraFeed

CameraFeed

A camera feed gives you access to a single physical camera attached to your device.

Class 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 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 CameraFeeds will be available. To get a CameraFeed on iOS, enable EditorExportPlatformIOS.modules/camera.

Properties

var feed_is_active: bool = false

If true, the feed is active.

var feed_transform: Transform2D = Transform2D(1, 0, 0, -1, 0, 1)

The transform applied to the camera's image.

var formats: Array = []

Formats supported by the feed. Each entry is a Dictionary describing format parameters.

Methods

func _activate_feed() -> bool

Called when the camera feed is activated.

func _deactivate_feed() -> void

Called when the camera feed is deactivated.

func _get_formats() -> Array

Override this method to define supported formats of the camera feed.

func _set_format(index: int, parameters: Dictionary) -> bool

Override this method to set the format of the camera feed.

func get_datatype() -> CameraFeed.FeedDataType

Returns feed image data type.

func get_id() -> int

Returns the unique ID for this feed.

func get_name() -> String

Returns the camera's name.

func get_position() -> CameraFeed.FeedPosition

Returns the position of camera on the device.

func get_texture_tex_id(feed_image_type: CameraServer.FeedImage) -> int

Returns the texture backend ID (usable by some external libraries that need a handle to a texture to write data).

func set_external(width: int, height: int) -> void

Sets the feed as external feed provided by another library.

func set_format(index: int, parameters: Dictionary) -> bool

Sets the feed format parameters for the given index in the formats array. Returns true on success. By default, the YUYV encoded stream is transformed to 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 FEED_YCBCR_SEP;

- "grayscale" will result in desaturated FEED_RGB;

- "copy" will result in FEED_YCBCR.

func set_name(name: String) -> void

Sets the camera's name.

func set_position(position: CameraFeed.FeedPosition) -> void

Sets the position of this camera.

func set_rgb_image(rgb_image: Image) -> void

Sets RGB image for this feed.

func set_ycbcr_image(ycbcr_image: Image) -> void

Sets YCbCr image for this feed.

func set_ycbcr_images(y_image: Image, cbcr_image: Image) -> void

Sets Y and CbCr images for this feed.

Inherited from RefCounted (4)
func init_ref() -> bool
func reference() -> bool
func unreference() -> bool
Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

signal format_changed()

Emitted when the format has changed.

signal frame_changed()

Emitted when a new frame is available.

Inherited from Object (2)

Enums & Constants

enum FeedDataType
FEED_NOIMAGE = 0

No image set for the feed.

FEED_RGB = 1

Feed supplies RGB images.

FEED_YCBCR = 2

Feed supplies YCbCr images that need to be converted to RGB.

FEED_YCBCR_SEP = 3

Feed supplies separate Y and CbCr images that need to be combined and converted to RGB.

FEED_EXTERNAL = 4

Feed supplies external image.

enum FeedPosition
FEED_UNSPECIFIED = 0

Unspecified position.

FEED_FRONT = 1

Camera is mounted at the front of the device.

FEED_BACK = 2

Camera is mounted at the back of the device.