VideoKitCameraManager

View Source Code

namespace VideoKit {
    /// <summary>
    /// Unity component for streaming the camera preview.
    /// </summary>
    class VideoKitCameraManager : MonoBehaviour { ... }
}

This components manages streaming pixel buffers from an CameraDevice in a scene. The component can be added to any game object in the scene.


Specifying the Capabilities

/// <summary>
/// Desired camera capabilities.
/// </summary>
Capabilities capabilities { get; set; } = 0;

INCOMPLETE

/// <summary>
/// Camera manager capabilities.
/// </summary>
[Flags]
enum Capabilities : int {
    /// <summary>
    /// Stream depth data along with the camera preview data.
    /// </summary>
    Depth           = 1,
    /// <summary>
    /// Generate a human texture from the camera preview stream.
    /// </summary>
    HumanTexture    = 6,
}

Configuring the Camera

INCOMPLETE

Specifying the Camera Facing

/// <summary>
/// Get or set the desired camera facing.
/// </summary>
Facing facing { get; set; } = Facing.User;

INCOMPLETE

/// <summary>
/// Camera facing.
/// </summary>
enum Facing : int {
    /// <summary>
    /// World-facing camera.
    /// </summary>
    World = 1,
    /// <summary>
    /// User-facing camera.
    /// </summary>
    User = 2,
}

Requiring the Specified Facing

/// <summary>
/// Whether the specified facing is required.
/// When false, the camera manager will fallback to a default camera when a camera with the requested facing is not available.
/// </summary>
bool facingRequired { get; set; } = false;

INCOMPLETE

Specifying the Preview Resolution

/// <summary>
/// Desired camera resolution.
/// </summary>
Resolution resolution { get; set; } = Resolution._1280x720;

INCOMPLETE

/// <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>
    /// 2K WQHD resolution.
    /// </summary>
    _2560x1440 = 6,
    /// <summary>
    /// 4K UHD resolution.
    /// </summary>
    _3840x2160  = 5,
    /// <summary>
    /// Highest resolution supported by the camera device.
    /// </summary>
    Highest     = 10
}

Specifying the Preview Frame Rate

/// <summary>
/// Desired camera frame rate.
/// </summary>
FrameRate frameRate { get; set; } = FrameRate._30;

INCOMPLETE

/// <summary>
/// Camera preview frame rate presets.
/// </summary>
enum FrameRate : int {
    /// <summary>
    /// Use the default camera frame rate.
    /// With this preset, the camera frame rate will not be set.
    /// </summary>
    Default = 0,
    /// <summary>
    /// Use the lowest frame rate supported by the camera.
    /// </summary>
    Lowest  = 1,
    /// <summary>
    /// 15FPS.
    /// </summary>
    _15     = 15,
    /// <summary>
    /// 30FPS.
    /// </summary>
    _30     = 30,
    /// <summary>
    /// 60FPS.
    /// </summary>
    _60     = 60,
    /// <summary>
    /// 120FPS.
    /// </summary>
    _120    = 120,
    /// <summary>
    /// 240FPS.
    /// </summary>
    _240    = 240
}

Specifying the Focus Mode

/// <summary>
/// Desired camera focus mode.
/// </summary>
CameraDevice.FocusMode focusMode { get; set; } = CameraDevice.FocusMode.Continuous;

INCOMPLETE

Specifying the Exposure Mode

/// <summary>
/// Desired camera exposure mode.
/// </summary>
CameraDevice.ExposureMode exposureMode { get; set; } = CameraDevice.ExposureMode.Continuous;

INCOMPLETE


Streaming Images

INCOMPLETE

Specifying the Camera Device

/// <summary>
/// Get or set the camera device used for streaming.
/// </summary>
CameraDevice? device { get; set; }

INCOMPLETE

Checking the Streaming Status

/// <summary>
/// Whether the camera device is running.
/// </summary>
bool running { get; }

INCOMPLETE

Starting the Stream

/// <summary>
/// Start the camera preview.
/// </summary>
void StartRunning ();

INCOMPLETE

Stopping the Stream

/// <summary>
/// Stop the camera preview.
/// </summary>
void StopRunning ();

INCOMPLETE


Listening for Pixel Buffers

/// <summary>
/// Event raised when a new camera image is provided by the camera device.
/// </summary>
event Action<CameraDevice, PixelBuffer> OnPixelBuffer { add; remove; }

INCOMPLETE


Was this page helpful?