VideoKitCameraManager
class VideoKit.VideoKitCameraManager : VideoKitDeviceManager<CameraDevice>
This components manages camera streaming in a scene. The component can be added to any game object in the scene.
The manager uses top-level properties to control which camera is used, the preview resolution, and whether to start streaming the preview immediately the scene is opened:
/// <summary>
/// Desired camera resolution.
/// </summary>
Resolution resolution { get; set; }
The
resolution
determines the preview resolution of the camera stream. The following resolution presets are supported:/// <summary>
/// Camera resolution presets.
/// </summary>
enum Resolution : int {
/// <summary>
/// Use the default camera resolution.
/// With this preset, the camera resolution will not be set.
/// </summary>
Default = 0,
/// <summary>
/// Lowest resolution supported by the camera device.
/// </summary>
Lowest = 1,
/// <summary>
/// SD resolution.
/// </summary>
_640x480 = 2,
/// <summary>
/// HD resolution.
/// </summary>
_1280x720 = 3,
/// <summary>
/// Full HD resolution.
/// </summary>
_1920x1080 = 4,
/// <summary>
/// 4K UHD resolution.
/// </summary>
_4K = 5,
/// <summary>
/// Highest resolution supported by the camera device.
/// Using this resolution is strongly not recommended.
/// </summary>
Highest = 10
}
The
resolution
is always specified in landscape format, meaning that the width is always greater than the height
./// <summary>
/// Desired camera capabilities.
/// </summary>
Capabilities capabilities { get; set; }
The
capabilities
are used to configure the camera session to provide certain types of data while streaming. The following capabilities are supported:/// <summary>
/// Camera manager capabilities.
/// </summary>
[Flags]
enum Capabilities {
/// <summary>
/// Stream depth data along with the camera preview data.
/// This flag adds a minimal performance cost, so enable it only when necessary.
/// </summary>
Depth = 1,
/// <summary>
/// Ensure that the camera preview data can be used for machine learning predictions.
/// Enabling this adds a minimal performance impact so it should be disabled when not needed.
/// </summary>
MachineLearning = 2,
/// <summary>
/// Generate a human segmentation texture while streaming the camera preview.
/// This flag adds a variable performance cost, so enable it only when necessary.
/// </summary>
HumanTexture = 6,
/// <summary>
/// Detect human pose data while streaming the camera preview.
/// This flag adds a variable performance cost, so enable it only when necessary.
/// </summary>
PoseDetection = 10,
}
On WebGL, the
MachineLearning
capability is always enabled./// <summary>
/// Whether to start the camera preview as soon as the component awakes.
/// </summary>
bool playOnAwake { get; set; }
The
playOnAwake
property determines whether to start the camera preview as soon as the component awakes.The manager provides some camera control properties:
/// <summary>
/// Get ot set the camera device used to stream camera images.
/// </summary>
CameraDevice device { get; set; }
The
device
used for streaming can be set. If the device is set while the preview is running, the manager will switch the camera to stream from the device that is set./// <summary>
/// Desired camera focus mode.
/// </summary>
CameraDevice.FocusMode focusMode { get; set; }
The
focusMode
property can be used to set the camera focus mode when starting the preview./// <summary>
/// Desired camera exposure mode.
/// </summary>
CameraDevice.ExposureMode exposureMode { get; set; }
The
exposureMode
property can be used to set the camera exposure mode when starting the preview./// <summary>
/// Whether the camera is running.
/// </summary>
bool running { get; }
The
running
property reports whether the camera preview is currently running.Because starting the camera preview is asynchronous, the value of this property is not guaranteed to be the same as
cameraDevice.running
. Use this property instead./// <summary>
/// Start the camera preview.
/// </summary>
void StartRunning ();
The camera preview is started with the
StartRunning
method./// <summary>
/// Stop the camera preview.
/// </summary>
void StopRunning ();
The camera preview is stopped with the
StopRunning
method./// <summary>
/// Event raised when the camera preview starts.
/// </summary>
UnityEvent<CameraFrame> OnCameraFrame { get; set; }
The
OnCameraFrame
event is raised with camera frames as they are streamed from the camera. This event can be used to implement video filters.Last modified 25d ago