VideoKitCameraManager

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.PreferUser;

INCOMPLETE

/// <summary>
/// Camera facing.
/// </summary>
enum Facing : int {
  /// <summary>
  /// Prefer a user-facing camera but enable fallback to any available camera.
  /// </summary>
  PreferUser = 0,
  /// <summary>
  /// Prefer a world-facing camera but enable fallback to any available camera.
  /// </summary>
  PreferWorld = 1,
  /// <summary>
  /// Require a user-facing camera.
  /// </summary>
  RequireUser = 2,
  /// <summary>
  /// Require a world-facing camera.
  /// </summary>
  RequireWorld = 3,
}

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


Accessing the Preview

INCOMPLETE

Retrieving the Preview Texture

/// <summary>
/// Get the camera preview texture.
/// </summary>
Texture2D? texture { get; }

INCOMPLETE

Retrieving the Human Texture

/// <summary>
/// Get the camera human texture.
/// This texture has the same size as the preview texture.
/// NOTE: 
/// </summary>
Texture2D? humanTexture { get; }

INCOMPLETE

Listening for Texture Updates

/// <summary>
/// Event raised when a new pixel buffer is available in the preview texture.
/// The preview texture and human texture will contain the latest pixel buffer.
/// </summary>
UnityEvent? OnCameraFrame { get; set; }

INCOMPLETE

Listening for Pixel Buffers

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

INCOMPLETE

Inspecting the Preview Rotation

/// <summary>
/// Get the camera preview rotation to become upright.
/// </summary>
PixelBuffer.Rotation rotation { get; }

INCOMPLETE


Was this page helpful?