CameraDevice
namespace VideoKit {
/// <summary>
/// Camera device for streaming pixel buffers.
/// </summary>
class CameraDevice { ... }
}
The CameraDevice
abstracts a hardware camera device capable of streaming pixel buffers.
Discovering Camera Devices
INCOMPLETE
Checking for Permissions
/// <summary>
/// Check the current camera permission status.
/// </summary>
/// <param name="request">Request permissions if the user has not yet been asked.</param>
/// <returns>Camera permission status.</returns>
static Task<PermissionStatus> CheckPermissions (bool request = true);
INCOMPLETE
/// <summary>
/// Device permissions status.
/// </summary>
enum PermissionStatus : int {
/// <summary>
/// User has not authorized or denied access to media device.
/// </summary>
Unknown = 0,
/// <summary>
/// User has denied access to media device.
/// </summary>
Denied = 2,
/// <summary>
/// User has authorized access to media device.
/// </summary>
Authorized = 3
}
Discovering Camera Devices
/// <summary>
/// Discover available camera devices.
/// </summary>
static Task<CameraDevice[]> Discover ();
INCOMPLETE
Identifying the Device
Camera devices can be identified in several ways:
Inspecting the Unique Identifier
/// <summary>
/// Camera unique ID.
/// </summary>
string uniqueId { get; }
The camera device reports its unique identifier as a string.
Inspecting the Camera Name
/// <summary>
/// Display friendly camera name.
/// </summary>
string name { get; }
The camera device reports its name as a human-friendly string.
Inspecting the Device Location
/// <summary>
/// Device location.
/// </summary>
Location location { get; }
Some camera devices are able to report their location relative to the current device.
See MediaDevice.Location
for more information.
Checking for the Default Device
/// <summary>
/// Whether this camera is the default camera device.
/// </summary>
bool defaultForMediaType { get; }
Some camera devices are able to report whether they are the default device for their media type.
Inspecting the Camera Properties
INCOMPLETE
Inspecting the Camera Facing
/// <summary>
/// Whether the camera is front facing.
/// </summary>
bool frontFacing { get; }
INCOMPLETE
Checking Flash Support
/// <summary>
/// Whether flash is supported for photo capture.
/// </summary>
bool flashSupported { get; }
INCOMPLETE
Checking Torch Support
/// <summary>
/// Whether torch is supported.
/// </summary>
bool torchSupported { get; }
INCOMPLETE
Checking Exposure Point Support
/// <summary>
/// Whether setting the exposure point is supported.
/// </summary>
bool exposurePointSupported { get; }
INCOMPLETE
Checking Focus Point Support
/// <summary>
/// Whether setting the focus point is supported.
/// </summary>
bool focusPointSupported { get; }
INCOMPLETE
Checking Depth Streaming Support
/// <summary>
/// Whether depth streaming is supported.
/// </summary>
bool depthStreamingSupported { get; }
INCOMPLETE
Inspecting the Field of View
/// <summary>
/// Field of view in degrees.
/// </summary>
(float width, float height) fieldOfView { get; }
INCOMPLETE
Inspecting the Exposure Bias Range
/// <summary>
/// Exposure bias range in EV.
/// </summary>
(float min, float max) exposureBiasRange { get; }
INCOMPLETE
Inspecting the Exposure Duration Range
/// <summary>
/// Exposure duration range in seconds.
/// </summary>
(float min, float max) exposureDurationRange { get; }
INCOMPLETE
Inspecting the Sensor Sensitivity Range
/// <summary>
/// Sensor sensitivity range.
/// </summary>
(float min, float max) ISORange { get; }
INCOMPLETE
Inspecting the Zoom Range
/// <summary>
/// Zoom ratio range.
/// </summary>
(float min, float max) zoomRange { get; }
INCOMPLETE
Streaming Pixel Buffers
The main function of the CameraDevice
is to stream pixel buffers.
Specifying the Preview Resolution
/// <summary>
/// Get or set the preview resolution.
/// </summary>
(int width, int height) previewResolution { get; set; }
INCOMPLETE
Specifying the Preview Frame Rate
/// <summary>
/// Get or set the preview framerate.
/// </summary>
float frameRate { get; set; }
INCOMPLETE
Checking the Streaming Status
/// <summary>
/// Whether the device is running.
/// </summary>
bool running { get; }
The camera device reports whether it is currently streaming pixel buffers.
Starting the Stream
/// <summary>
/// Start the camera preview.
/// </summary>
/// <param name="handler">Delegate to receive preview image frames.</param>
void StartRunning (Action<PixelBuffer> handler);
INCOMPLETE
The provided handler
is invoked on a dedicated camera thread, not the Unity main thread.
Stopping the Stream
/// <summary>
/// Stop running.
/// </summary>
void StopRunning ();
When the camera device is running, this method can be used to stop streaming pixel buffers and cleanup resources.
Configuring the Camera
INCOMPLETE
Specifying the Exposure Mode
/// <summary>
/// Get or set the exposure mode.
/// If the requested exposure mode is not supported, the camera device will ignore.
/// </summary>
ExposureMode exposureMode { get; set; } = ExposureMode.Continuous;
INCOMPLETE
/// <summary>
/// Check if a given exposure mode is supported by the camera device.
/// </summary>
/// <param name="mode">Exposure mode.</param>
bool IsExposureModeSupported (ExposureMode mode);
INCOMPLETE
/// <summary>
/// Exposure mode.
/// </summary>
enum ExposureMode : int {
/// <summary>
/// Continuous auto exposure.
/// </summary>
Continuous = 0,
/// <summary>
/// Locked auto exposure.
/// </summary>
Locked = 1,
/// <summary>
/// Manual exposure.
/// </summary>
Manual = 2
}
Specifying the Exposure Point
/// <summary>
/// Set the exposure point of interest.
/// The point is specified in normalized coordinates in range [0.0, 1.0].
/// </summary>
/// <param name="x">Normalized x coordinate.</param>
/// <param name="y">Normalized y coordinate.</param>
void SetExposurePoint (float x, float y);
INCOMPLETE
Specifying the Exposure Bias
/// <summary>
/// Get or set the exposure bias.
/// This value must be in the range returned by `exposureRange`.
/// </summary>
float exposureBias { get; set; }
INCOMPLETE
Specifying the Exposure Duration
/// <summary>
/// Get or set the current exposure duration in seconds.
/// </summary>
float exposureDuration { get; }
INCOMPLETE
/// <summary>
/// Get or set the current exposure sensitivity.
/// </summary>
float ISO { get; }
INCOMPLETE
/// <summary>
/// Set manual exposure.
/// </summary>
/// <param name="duration">Exposure duration in seconds. MUST be in `exposureDurationRange`.</param>
/// <param name="ISO">Sensor sensitivity ISO value. MUST be in `ISORange`.</param>
void SetExposureDuration (float duration, float ISO);
Specifying the Flash Mode
/// <summary>
/// Get or set the photo flash mode.
/// </summary>
FlashMode flashMode { get; set; }
INCOMPLETE
/// <summary>
/// Photo flash mode.
/// </summary>
enum FlashMode : int {
/// <summary>
/// Never use flash.
/// </summary>
Off = 0,
/// <summary>
/// Always use flash.
/// </summary>
On = 1,
/// <summary>
/// Let the sensor detect if it needs flash.
/// </summary>
Auto = 2
}
Specifying the Focus Mode
/// <summary>
/// Get or set the focus mode.
/// </summary>
FocusMode focusMode { get; set; }
INCOMPLETE
/// <summary>
/// Check if a given focus mode is supported by the camera device.
/// </summary>
/// <param name="mode">Focus mode.</param>
bool IsFocusModeSupported (FocusMode mode);
INCOMPLETE
/// <summary>
/// Focus mode.
/// </summary>
enum FocusMode : int {
/// <summary>
/// Continuous autofocus.
/// </summary>
Continuous = 0,
/// <summary>
/// Locked focus.
/// </summary>
Locked = 1,
}
Specifying the Focus Point
/// <summary>
/// Set the focus point of interest.
/// The point is specified in normalized coordinates in range [0.0, 1.0].
/// </summary>
/// <param name="x">Normalized x coordinate.</param>
/// <param name="y">Normalized y coordinate.</param>
void SetFocusPoint (float x, float y);
INCOMPLETE
Specifying the Torch Mode
/// <summary>
/// Get or set the torch mode.
/// </summary>
TorchMode torchMode { get; set; }
INCOMPLETE
/// <summary>
/// Torch mode.
/// </summary>
enum TorchMode : int {
/// <summary>
/// Disabled torch.
/// </summary>
Off = 0,
/// <summary>
/// Maximum supported torch level.
/// </summary>
Maximum = 100
}
Specifying the White Balance Mode
/// <summary>
/// Get or set the white balance mode.
/// </summary>
WhiteBalanceMode whiteBalanceMode { get; set; }
INCOMPLETE
/// <summary>
/// Check if a given white balance mode is supported by the camera device.
/// </summary>
/// <param name="mode">White balance mode.</param>
bool IsWhiteBalanceModeSupported (WhiteBalanceMode mode);
INCOMPLETE
/// <summary>
/// White balance mode.
/// </summary>
enum WhiteBalanceMode : int {
/// <summary>
/// Continuous auto white balance.
/// </summary>
Continuous = 0,
/// <summary>
/// Locked auto white balance.
/// </summary>
Locked = 1,
}
Specifying the Video Stabilization Mode
/// <summary>
/// Get or set the video stabilization mode.
/// </summary>
VideoStabilizationMode videoStabilizationMode { get; set; }
INCOMPLETE
/// <summary>
/// Check if a given video stabilization mode is supported by the camera device.
/// </summary>
/// <param name="mode">Video stabilization mode.</param>
bool IsVideoStabilizationModeSupported (VideoStabilizationMode mode);
INCOMPLETE
/// <summary>
/// Video stabilization mode.
/// </summary>
enum VideoStabilizationMode : int {
/// <summary>
/// Disabled video stabilization.
/// </summary>
Off = 0,
/// <summary>
/// Standard video stabilization.
/// </summary>
Standard = 1
}
Specifying the Zoom Ratio
/// <summary>
/// Get or set the zoom ratio.
/// This value must be in the range returned by `zoomRange`.
/// </summary>
float zoomRatio { get; set; }
INCOMPLETE
Capturing Photos
INCOMPLETE
Specifying the Photo Resolution
/// <summary>
/// Get or set the photo resolution.
/// </summary>
(int width, int height) photoResolution { get; set; }
INCOMPLETE
Capturing a Photo
/// <summary>
/// Capture a photo.
/// </summary>
/// <param name="handler">Delegate to receive high-resolution photo.</param>
void CapturePhoto (Action<PixelBuffer> handler);
INCOMPLETE
The provided handler
is invoked on a dedicated camera thread, not the Unity main thread.