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.
Checking the stable version of the documentation...
CameraFeed
继承: RefCounted < Object
通过相机源,你可以访问连接到设备的单个物理相机。
描述
通过相机源,你可以访问连接到设备的单个物理相机。启用后,Godot 将开始从相机捕获帧,随后这些帧便可使用。另见 CameraServer。
注意:很多相机会返回 YCbCr 图像,这些图像被分成两个纹理,需要在着色器中组合。如果你将环境设置为在背景中显示相机图像,Godot 会自动执行此操作。
注意:这个类目前只在 Linux、macOS 和 iOS 上实现。在其他平台上没有可用的 CameraFeed。在 iOS 上获取 CameraFeed 需要来自 godot-ios-plugins 的相机插件。
属性
|
||
|
||
|
方法
_activate_feed() virtual |
|
void |
_deactivate_feed() virtual |
get_datatype() const |
|
get_id() const |
|
get_name() const |
|
get_position() const |
|
get_texture_tex_id(feed_image_type: FeedImage) |
|
void |
set_external(width: int, height: int) |
set_format(index: int, parameters: Dictionary) |
|
void |
|
void |
set_position(position: FeedPosition) |
void |
set_rgb_image(rgb_image: Image) |
void |
set_ycbcr_image(ycbcr_image: Image) |
信号
format_changed() 🔗
格式发生变化时发出。
frame_changed() 🔗
新图像帧可用时发出。
枚举
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
源提供外部图像。
enum FeedPosition: 🔗
FeedPosition FEED_UNSPECIFIED = 0
未指定坐标。
FeedPosition FEED_FRONT = 1
相机安装在了设备前部。
FeedPosition FEED_BACK = 2
相机安装在了设备后部。
属性说明
如果为 true
,则源是激活的。
Transform2D feed_transform = Transform2D(1, 0, 0, -1, 0, 1)
🔗
void set_transform(value: Transform2D)
Transform2D get_transform()
应用于相机图像的变换。
Array get_formats()
源支持的所有格式。每个条目都是描述格式参数的 Dictionary。
方法说明
bool _activate_feed() virtual 🔗
相机源被激活时调用。
void _deactivate_feed() virtual 🔗
相机源失去激活时调用。
FeedDataType get_datatype() const 🔗
返回源图像的数据类型。
返回该源的唯一ID。
返回相机的名称。
FeedPosition get_position() const 🔗
返回设备上的相机位置。
int get_texture_tex_id(feed_image_type: FeedImage) 🔗
返回纹理后端的 ID(可用于某些需要通过纹理句柄写入数据的外部库)。
void set_external(width: int, height: int) 🔗
将供给设置为由另一个库提供的外部供给。
bool set_format(index: int, parameters: Dictionary) 🔗
为源格式数组 formats 中给定索引的元素设置格式参数。成功则返回 true
。默认会将 YUYV 编码的流转换为 FEED_RGB。YUYV 编码的流的输出格式可以使用 parameters
.output 修改:
separate
得到的是 FEED_YCBCR_SEP
grayscale
得到的是降低饱和度的 FEED_RGB
copy
得到的是 FEED_YCBCR
设置相机的名称。
void set_position(position: FeedPosition) 🔗
设置相机的位置。
void set_rgb_image(rgb_image: Image) 🔗
设置该源的 RGB 图像。
void set_ycbcr_image(ycbcr_image: Image) 🔗
设置该源的 YCbCr 图像。