Class CameraController
The Raspberry Pi's camera controller wrapping raspistill and raspivid programs. This class is a singleton.
Namespace: Unosquare.RaspberryIO.Camera
Syntax
public class CameraController : SingletonBase<CameraController>
Properties
IsBusy
Gets a value indicating whether the camera module is busy.
Declaration
public bool IsBusy { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
Methods
CaptureImage(CameraStillSettings)
Captures an image.
Declaration
public byte[] CaptureImage(CameraStillSettings settings)
Parameters
Type | Name | Description |
---|---|---|
CameraStillSettings | settings | The settings. |
Returns
Type | Description |
---|---|
Byte[] | The image bytes. |
CaptureImageAsync(CameraStillSettings, CancellationToken)
Captures an image asynchronously.
Declaration
public Task<byte[]> CaptureImageAsync(CameraStillSettings settings, CancellationToken ct = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
CameraStillSettings | settings | The settings. |
CancellationToken | ct | The ct. |
Returns
Type | Description |
---|---|
Task<Byte[]> | The image bytes. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Cannot use camera module because it is currently busy. |
CaptureImageJpeg(Int32, Int32)
Captures a JPEG encoded image at 90% quality.
Declaration
public byte[] CaptureImageJpeg(int width, int height)
Parameters
Type | Name | Description |
---|---|---|
Int32 | width | The width. |
Int32 | height | The height. |
Returns
Type | Description |
---|---|
Byte[] | The image bytes. |
CaptureImageJpegAsync(Int32, Int32, CancellationToken)
Captures a JPEG encoded image asynchronously at 90% quality.
Declaration
public Task<byte[]> CaptureImageJpegAsync(int width, int height, CancellationToken ct = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Int32 | width | The width. |
Int32 | height | The height. |
CancellationToken | ct | The ct. |
Returns
Type | Description |
---|---|
Task<Byte[]> | The image bytes. |
CloseVideoStream()
Closes the video stream of a video stream is open.
Declaration
public void CloseVideoStream()
OpenVideoStream(Action<Byte[]>, Action)
Opens the video stream with a timeout of 0 (running indefinitely) at 1080p resolution, variable bitrate and 25 FPS. No preview is shown.
Declaration
public void OpenVideoStream(Action<byte[]> onDataCallback, Action onExitCallback = null)
Parameters
Type | Name | Description |
---|---|---|
Action<Byte[]> | onDataCallback | The on data callback. |
Action | onExitCallback | The on exit callback. |
OpenVideoStream(CameraVideoSettings, Action<Byte[]>, Action)
Opens the video stream with the supplied settings. Capture Timeout Milliseconds has to be 0 or greater.
Declaration
public void OpenVideoStream(CameraVideoSettings settings, Action<byte[]> onDataCallback, Action onExitCallback = null)
Parameters
Type | Name | Description |
---|---|---|
CameraVideoSettings | settings | The settings. |
Action<Byte[]> | onDataCallback | The on data callback. |
Action | onExitCallback | The on exit callback. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Cannot use camera module because it is currently busy. |
ArgumentException | CaptureTimeoutMilliseconds. |