Skip to main content

DcmiController Class

Package: GHIElectronics.Endpoint.Devices.Camera
Namespace: GHIElectronics.Endpoint.Devices.Camera

Base controller for the board's parallel camera-interface port. Reserves the camera data and sync pins, drives the pixel clock, loads the backing kernel module, and exposes single-frame capture and streaming. Concrete sensor drivers derive from this type.

public abstract class DcmiController : IDisposable

Nested Types​

TypeKindSummary
DcmiController.FrameReceivedEventHandlerDelegateHandler for a single captured frame from the sensor.

Constructors​

DcmiController(string devicePath)​

public DcmiController(string devicePath)

Reserves the camera-interface pins, starts the pixel clock, and loads the backing capture driver. The V4L2 node is not opened until DcmiController.Open is called.

ParameterTypeDescription
devicePathstringV4L2 device node for the capture, defaulting to /dev/video0.

Properties​

Height​

public int Height { get; }

Frame height in pixels, taken from the last applied DcmiController.Setting.

Returns int

IsVideoStreaming​

public bool IsVideoStreaming { get; }

true while DcmiController.VideoStreamStart is delivering frames via DcmiController.FrameReceived.

Returns bool

Setting​

public CameraConfiguration Setting { get; set; }

Resolution, pixel format and frame rate for subsequent captures. Assigning a value re-initializes the native device at the new size, FPS and JPEG quality, and reallocates the internal frame buffer.

Returns CameraConfiguration

Width​

public int Width { get; }

Frame width in pixels, taken from the last applied DcmiController.Setting.

Returns int

Methods​

Capture()​

public byte[] Capture()

Captures a single frame synchronously and returns it in the format set by CameraConfiguration.ImageFormat. Throws if DcmiController.Setting is unset, the device is not open, or a video stream is already running.

Returns byte[]: Frame bytes, or null if the sensor returned no valid JPEG.

Close()​

protected void Close()

Stops streaming (if active) and closes the V4L2 device. Safe to call when already closed.

Dispose()​

public void Dispose()

Closes the device, releases the camera-interface pins, stops the pixel clock and unloads the backing capture driver.

Dispose(bool disposing)​

protected void Dispose(bool disposing)

Releases held resources. See DcmiController.Dispose.

ParameterTypeDescription
disposingbooltrue when called from DcmiController.Dispose; false from a finalizer.

GetResolution()​

public string[] GetResolution()

Lists every WIDTHxHEIGHT resolution the capture driver reports from v4l2-ctl --list-formats-ext, or null if none are found.

Returns string[]

Open()​

protected void Open()

Opens the V4L2 device for capture. Throws if the device is already open or the node does not exist.

VideoStreamStart()​

public void VideoStreamStart()

Begins continuous capture on a background task; each frame is delivered through DcmiController.FrameReceived. Throws if DcmiController.Setting is unset or the device is not open. Call DcmiController.VideoStreamStop to end streaming.

VideoStreamStop()​

public void VideoStreamStop()

Signals the streaming worker to stop and blocks until it has exited.

Events​

FrameReceived​

public event FrameReceivedEventHandler FrameReceived

Fires on the streaming worker thread for every frame captured by DcmiController.VideoStreamStart. Not raised by DcmiController.Capture.