Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

CameraFeed

繼承: RefCounted < Object

通過相機源,你可以存取連接到裝置的單個物理相機。

說明

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.

屬性

bool

feed_is_active

false

Transform2D

feed_transform

Transform2D(1, 0, 0, -1, 0, 1)

Array

formats

[]

方法

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: 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)


訊號

format_changed() 🔗

Emitted when the format has changed.


frame_changed() 🔗

Emitted when a new frame is available.


列舉

enum FeedDataType: 🔗

FeedDataType FEED_NOIMAGE = 0

沒有為該源設定圖像。

FeedDataType FEED_RGB = 1

源提供 RGB 圖像。

FeedDataType FEED_YCBCR = 2

源提供的 YCbCr 圖像需要轉換成 RGB 圖像。

FeedDataType FEED_YCBCR_SEP = 3

源提供單獨的 Y 和 CbCr 圖像,需要合併並轉換為 RGB。

FeedDataType FEED_EXTERNAL = 4

Feed supplies external image.


enum FeedPosition: 🔗

FeedPosition FEED_UNSPECIFIED = 0

未指定座標。

FeedPosition FEED_FRONT = 1

相機安裝在了裝置前部。

FeedPosition FEED_BACK = 2

相機安裝在了裝置後部。


屬性說明

bool feed_is_active = false 🔗

  • void set_active(value: bool)

  • bool is_active()

如果為 true,則源是啟動的。


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

套用於相機圖像的變換。


Array formats = [] 🔗

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


方法說明

bool _activate_feed() virtual 🔗

Called when the camera feed is activated.


void _deactivate_feed() virtual 🔗

Called when the camera feed is deactivated.


Array _get_formats() virtual const 🔗

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


bool _set_format(index: int, parameters: Dictionary) virtual 🔗

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


FeedDataType get_datatype() const 🔗

返回源圖像的資料型別。


int get_id() const 🔗

返回該源的唯一ID。


String get_name() const 🔗

返回相機的名稱。


FeedPosition get_position() const 🔗

返回裝置上的相機位置。


int get_texture_tex_id(feed_image_type: FeedImage) 🔗

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


void set_external(width: int, height: int) 🔗

Sets the feed as external feed provided by another library.


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:


void set_name(name: String) 🔗

Sets the camera's name.


void set_position(position: FeedPosition) 🔗

Sets the position of this camera.


void set_rgb_image(rgb_image: Image) 🔗

Sets RGB image for this feed.


void set_ycbcr_image(ycbcr_image: Image) 🔗

Sets YCbCr image for this feed.


void set_ycbcr_images(y_image: Image, cbcr_image: Image) 🔗

Sets Y and CbCr images for this feed.