Table of Contents

Class CameraFeed

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

Inheritance
CameraFeed

Remarks

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, 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

feed_is_active

If true, the feed is active.

var feed_is_active : bool = false

Property Value

bool

Remarks

  • void set_active(bool value)
  • bool is_active

feed_transform

The transform applied to the camera's image.

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

Property Value

Transform2D

Remarks

formats

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

var formats : Array = []

Property Value

Array

Remarks

Methods

_activate_feed

Qualifiers: virtual

Called when the camera feed is activated.

bool _activate_feed

_deactivate_feed

Qualifiers: virtual

Called when the camera feed is deactivated.

void _deactivate_feed

get_datatype

Qualifiers: const

Returns feed image data type.

int get_datatype

get_id

Qualifiers: const

Returns the unique ID for this feed.

int get_id

get_name

Qualifiers: const

Returns the camera's name.

String get_name

get_position

Qualifiers: const

Returns the position of camera on the device.

int get_position

get_texture_tex_id(int)

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

int get_texture_tex_id(int feed_image_type)

Parameters

feed_image_type int

set_external(int, int)

Sets the feed as external feed provided by another library.

void set_external(int width, int height)

Parameters

width int
height int

set_format(int, Dictionary)

Sets the feed format parameters for the given index in the formats array. Returns true on success. By default YUYV encoded stream is transformed to FEED_RGB. YUYV encoded stream output format can be changed with parameters.output value:

separate will result in FEED_YCBCR_SEP

grayscale will result in desaturated FEED_RGB

copy will result in FEED_YCBCR

bool set_format(int index, Dictionary parameters)

Parameters

index int
parameters Dictionary

set_name(String)

Sets the camera's name.

void set_name(String name)

Parameters

name String

set_position(int)

Sets the position of this camera.

void set_position(int position)

Parameters

position int

set_rgb_image(Image)

Sets RGB image for this feed.

void set_rgb_image(Image rgb_image)

Parameters

rgb_image Image

set_ycbcr_image(Image)

Sets YCbCr image for this feed.

void set_ycbcr_image(Image ycbcr_image)

Parameters

ycbcr_image Image

Events

format_changed

Emitted when the format has changed.

signal format_changed

frame_changed

Emitted when a new frame is available.

signal frame_changed