CameraFeed
Inherits: RefCounted < Object
Description
Section titled “Description”A camera feed gives you access to a single physical camera attached to your device.
A camera feed gives you access to a single physical camera attached to your device. When enabled, Orblit will start capturing frames from the camera which can then be used. See also CameraSystem.
Note: Many cameras will return YCbCr images which are split into two textures and need to be combined in a shader. Orblit 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
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| bool | feed_is_active |
false |
| Transform2D | feed_transform |
Transform2D(1, 0, 0, -1, 0, 1) |
| Array | formats |
[] |
Methods
Section titled “Methods”| Returns | Method |
|---|---|
| bool | _activate_feed() virtual |
| void | _deactivate_feed() virtual |
| Array | _get_formats() virtual const |
| bool | _set_format(index: int, parameters: Dictionary) virtual |
| FeedDataType | get_datatype() const |
| int | get_id() const |
| String | get_name() const |
| FeedPosition | get_position() const |
| int | get_texture_tex_id(feed_image_type: CameraSystem.FeedImage) |
| void | set_external(width: int, height: int) |
| bool | set_format(index: int, parameters: Dictionary) |
| void | set_name(name: String) |
| void | set_position(position: FeedPosition) |
| void | set_rgb_image(rgb_image: Image) |
| void | set_ycbcr_image(ycbcr_image: Image) |
| void | set_ycbcr_images(y_image: Image, cbcr_image: Image) |
Signals
Section titled “Signals”format_changed
format_changed()
Emitted when the format has changed.
frame_changed
frame_changed()
Emitted when a new frame is available.
Enumerations
Section titled “Enumerations”FeedDataType
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.
FeedPosition
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.
Property descriptions
Section titled “Property descriptions”feed_is_active
bool feed_is_active = false
If true, the feed is active.
feed_transform
Transform2D feed_transform = Transform2D(1, 0, 0, -1, 0, 1)
The transform applied to the camera’s image.
formats
Array formats = []
Formats supported by the feed. Each entry is a Dictionary describing format parameters.
Method descriptions
Section titled “Method descriptions”_activate_feed
bool _activate_feed() virtual
Called when the camera feed is activated.
_deactivate_feed
void _deactivate_feed() virtual
Called when the camera feed is deactivated.
_get_formats
Array _get_formats() virtual const
Override this method to define supported formats of the camera feed.
_set_format
bool _set_format(index: int, parameters: Dictionary) virtual
Override this method to set the format of the camera feed.
get_datatype
FeedDataType get_datatype() const
Returns feed image data type.
get_id
int get_id() const
Returns the unique ID for this feed.
get_name
String get_name() const
Returns the camera’s name.
get_position
FeedPosition get_position() const
Returns the position of camera on the device.
get_texture_tex_id
int get_texture_tex_id(feed_image_type: CameraSystem.FeedImage)
Returns the texture backend ID (usable by some external libraries that need a handle to a texture to write data).
set_external
void set_external(width: int, height: int)
Sets the feed as external feed provided by another library.
set_format
bool set_format(index: int, parameters: Dictionary)
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 inFEED_YCBCR_SEP; -
"grayscale"will result in desaturatedFEED_RGB; -
"copy"will result inFEED_YCBCR.
set_name
void set_name(name: String)
Sets the camera’s name.
set_position
void set_position(position: FeedPosition)
Sets the position of this camera.
set_rgb_image
void set_rgb_image(rgb_image: Image)
Sets RGB image for this feed.
set_ycbcr_image
void set_ycbcr_image(ycbcr_image: Image)
Sets YCbCr image for this feed.
set_ycbcr_images
void set_ycbcr_images(y_image: Image, cbcr_image: Image)
Sets Y and CbCr images for this feed.
