| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="CameraServer" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Server keeping track of different cameras accessible in Godot. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | The [CameraServer] keeps track of different cameras accessible in Godot. These are external cameras such as webcams or the cameras on your phone. |
| 8 | It is notably used to provide AR modules with a video feed from the camera. |
| 9 | [b]Note:[/b] This class is currently only implemented on Linux, Android, macOS, and iOS. On other platforms no [CameraFeed]s will be available. To get a [CameraFeed] on iOS, the camera plugin from [url=https://github.com/godotengine/godot-ios-plugins]godot-ios-plugins[/url] is required. |
| 10 | </description> |
| 11 | <tutorials> |
| 12 | </tutorials> |
| 13 | <methods> |
| 14 | <method name="add_feed"> |
| 15 | <return type="void" /> |
| 16 | <param index="0" name="feed" type="CameraFeed" /> |
| 17 | <description> |
| 18 | Adds the camera [param feed] to the camera server. |
| 19 | </description> |
| 20 | </method> |
| 21 | <method name="feeds"> |
| 22 | <return type="CameraFeed[]" /> |
| 23 | <description> |
| 24 | Returns an array of [CameraFeed]s. |
| 25 | </description> |
| 26 | </method> |
| 27 | <method name="get_feed"> |
| 28 | <return type="CameraFeed" /> |
| 29 | <param index="0" name="index" type="int" /> |
| 30 | <description> |
| 31 | Returns the [CameraFeed] corresponding to the camera with the given [param index]. |
| 32 | </description> |
| 33 | </method> |
| 34 | <method name="get_feed_count"> |
| 35 | <return type="int" /> |
| 36 | <description> |
| 37 | Returns the number of [CameraFeed]s registered. |
| 38 | </description> |
| 39 | </method> |
| 40 | <method name="remove_feed"> |
| 41 | <return type="void" /> |
| 42 | <param index="0" name="feed" type="CameraFeed" /> |
| 43 | <description> |
| 44 | Removes the specified camera [param feed]. |
| 45 | </description> |
| 46 | </method> |
| 47 | </methods> |
| 48 | <members> |
| 49 | <member name="monitoring_feeds" type="bool" setter="set_monitoring_feeds" getter="is_monitoring_feeds" default="false"> |
| 50 | If [code]true[/code], the server is actively monitoring available camera feeds. |
| 51 | This has a performance cost, so only set it to [code]true[/code] when you're actively accessing the camera. |
| 52 | [b]Note:[/b] After setting it to [code]true[/code], you can receive updated camera feeds through the [signal camera_feeds_updated] signal. |
| 53 | [codeblocks] |
| 54 | [gdscript] |
| 55 | func _ready(): |
| 56 | CameraServer.camera_feeds_updated.connect(_on_camera_feeds_updated) |
| 57 | CameraServer.monitoring_feeds = true |
| 58 | |
| 59 | func _on_camera_feeds_updated(): |
| 60 | var feeds = CameraServer.feeds() |
| 61 | [/gdscript] |
| 62 | [csharp] |
| 63 | public override void _Ready() |
| 64 | { |
| 65 | CameraServer.CameraFeedsUpdated += OnCameraFeedsUpdated; |
| 66 | CameraServer.MonitoringFeeds = true; |
| 67 | } |
| 68 | |
| 69 | void OnCameraFeedsUpdated() |
| 70 | { |
| 71 | var feeds = CameraServer.Feeds(); |
| 72 | } |
| 73 | [/csharp] |
| 74 | [/codeblocks] |
| 75 | </member> |
| 76 | </members> |
| 77 | <signals> |
| 78 | <signal name="camera_feed_added"> |
| 79 | <param index="0" name="id" type="int" /> |
| 80 | <description> |
| 81 | Emitted when a [CameraFeed] is added (e.g. a webcam is plugged in). |
| 82 | </description> |
| 83 | </signal> |
| 84 | <signal name="camera_feed_removed"> |
| 85 | <param index="0" name="id" type="int" /> |
| 86 | <description> |
| 87 | Emitted when a [CameraFeed] is removed (e.g. a webcam is unplugged). |
| 88 | </description> |
| 89 | </signal> |
| 90 | <signal name="camera_feeds_updated"> |
| 91 | <description> |
| 92 | Emitted when camera feeds are updated. |
| 93 | </description> |
| 94 | </signal> |
| 95 | </signals> |
| 96 | <constants> |
| 97 | <constant name="FEED_RGBA_IMAGE" value="0" enum="FeedImage"> |
| 98 | The RGBA camera image. |
| 99 | </constant> |
| 100 | <constant name="FEED_YCBCR_IMAGE" value="0" enum="FeedImage"> |
| 101 | The [url=https://en.wikipedia.org/wiki/YCbCr]YCbCr[/url] camera image. |
| 102 | </constant> |
| 103 | <constant name="FEED_Y_IMAGE" value="0" enum="FeedImage"> |
| 104 | The Y component camera image. |
| 105 | </constant> |
| 106 | <constant name="FEED_CBCR_IMAGE" value="1" enum="FeedImage"> |
| 107 | The CbCr component camera image. |
| 108 | </constant> |
| 109 | </constants> |
| 110 | </class> |