Class reference

CameraFeed

Inherits RefCounted

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

Description

A camera feed gives you access to a single physical camera attached to your device. When enabled, Redot 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. Redot 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, the camera plugin from godot-ios-plugins is required.

Properties

bool feed_is_active = false

If true, the feed is active.

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

The transform applied to the camera's image.

Array formats = []

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

Methods

bool _activate_feed() virtual

Called when the camera feed is activated.

void _deactivate_feed() virtual

Called when the camera feed is deactivated.

int get_datatype() const

Returns feed image data type.

int get_id() const

Returns the unique ID for this feed.

String get_name() const

Returns the camera's name.

int get_position() const

Returns the position of camera on the device.

int get_texture_tex_id(int feed_image_type)

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

void set_external(int width, int height)

Sets the feed as external feed provided by another library.

bool set_format(int index, Dictionary parameters)

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.

void set_name(String name)

Sets the camera's name.

void set_position(int position)

Sets the position of this camera.

void set_rgb_image(Image rgb_image)

Sets RGB image for this feed.

void set_ycbcr_image(Image ycbcr_image)

Sets YCbCr image for this feed.

Signals

format_changed()

Emitted when the format has changed.

frame_changed()

Emitted when a new frame is available.

Constants

FEED_NOIMAGE = 0

Enum: FeedDataType

No image set for the feed.

FEED_RGB = 1

Enum: FeedDataType

Feed supplies RGB images.

FEED_YCBCR = 2

Enum: FeedDataType

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

FEED_YCBCR_SEP = 3

Enum: FeedDataType

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

FEED_EXTERNAL = 4

Enum: FeedDataType

Feed supplies external image.

FEED_UNSPECIFIED = 0

Enum: FeedPosition

Unspecified position.

FEED_FRONT = 1

Enum: FeedPosition

Camera is mounted at the front of the device.

FEED_BACK = 2

Enum: FeedPosition

Camera is mounted at the back of the device.

Source revision 4f5b14abade2
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.