WebcamSource
Manages the webcam functionality.
Inherits StreamSource class.
Constructors
Name | Description |
---|---|
WebcamSource() | Creates a new WebcamSource object. |
Properties
Name | Type | Description |
---|---|---|
WebcamIndex | int | Read-Only. The webcam device index. |
WebcamTexture | Read-Only. The WebcamTexture onto which the live video input is rendered. | |
Timestamp | DateTime | Read-Only. Overriden. The frame timestamp. |
IsOpen | bool | Read-Only. If the camera is currently playing and its Width and Height are greater than 16 pixels each. |
IsPlaying | bool | Read-Only. If the camera is currently playing. |
Width | int | Read-Only. Overriden. The width of the WebcamTexture in pixels. |
Height | int | Read-Only. Overriden. The height of the WebcamTexture in pixels. |
Rotation | int | Read-Only. Overriden. The rotation of the camera. |
Pixels | Read-Only. Overriden. The pixel color data for a mipmap level as Color32 structs. | |
Pointer | IntPtr | Read-Only. Overriden. A native pointer to the WebcamTexture resource. |
Methods
Name | Return Type | Description |
---|---|---|
Open | void | Starts the camera if the app is granted access. |
Close | void | Closes the camera. |
Pause | void | Pauses the camera. |
SwitchCamera(int) | void | Closes the open camera and opens the camera with the specified device index. |
Example
The example shows how to manage webcam functionality with the WebcamSource
class.
Create a WebcamSource
To create a Webcam
Source, add a field for Unity to serialize.
Open webcam
Open the webcam to get the live feed.
Get camera feed
To get the camera feed, first add an ImageView
field for Unity to serialize. Then, if the webcam is open and has a new frame, draw the texture.
Close webcam
Close the webcam to stop the live feed.
Last updated