Camera
TinyCLR supports the Digital Camera Interface (DCMI) on SITCore SC20260-based devices — a parallel video input that DMA's frames directly into RAM with no per-frame CPU work. Most camera modules also need a small I²C configuration step at startup (resolution, format, gain, etc.) before they'll stream.
NuGet packages: GHIElectronics.TinyCLR.Devices.I2c for the configuration bus, plus a camera-specific driver. The GHIElectronics.TinyCLR.Drivers.Omnivision.Ov9655 driver is the canonical reference — its source in the TinyCLR-Drivers repo shows how the I²C config sequence is built and is a useful template if you're adapting another camera.
Capturing and displaying frames
The example below targets the SCM20260D Dev Board with the 4.3" parallel display and an OmniVision OV9655 camera. It configures the camera for VGA (640×480), captures frames in a loop, and pushes each one to the display via DrawBuffer.
The display setup is the same as on the Displays → Native displays page — only the camera-specific code is shown below.
using GHIElectronics.TinyCLR.Devices.Display;
using GHIElectronics.TinyCLR.Devices.I2c;
using GHIElectronics.TinyCLR.Drivers.Omnivision.Ov9655;
using GHIElectronics.TinyCLR.Pins;
using System.Diagnostics;
using System.Threading;
// ... display setup (see Graphics → Native displays). `displayController` is the result.
var i2c = I2cController.FromName(SC20260.I2cBus.I2c1);
var camera = new Ov9655Controller(i2c);
camera.FrameReceived += (data, size) => {
// Display is 480x272; the camera frame is 640x480 (VGA).
// DrawBuffer clips the wider frame to the panel.
displayController.DrawBuffer(0, 0, 0, 0, 480, 272, sourceWidth: 640, data, 0);
};
Debug.WriteLine("Camera ID: " + camera.ReadId());
camera.SetResolution(Ov9655Controller.Resolution.Vga);
while (true) {
try {
camera.Capture();
}
catch (System.Exception ex) {
Debug.WriteLine("Capture failed: " + ex.Message);
}
Thread.Sleep(10);
}
The FrameReceived event fires once per completed frame with the raw pixel data and its size. The DrawBuffer call lets you crop or downscale by passing the source frame width separately from the destination panel dimensions — handy when the camera's native resolution differs from the panel.
Capturing without a display
If you're not showing frames on a panel (saving to SD card, sending over the network, running a vision algorithm), drop the display setup entirely and consume the frame bytes in FrameReceived:
camera.FrameReceived += (data, size) => {
// data is the raw frame buffer; size is its length in bytes.
// Write it, transmit it, process it.
};
The frame format depends on what you configured the camera for — see your camera's driver and datasheet for the layout.
API reference
| Namespace | Description |
|---|---|
| GHIElectronics.TinyCLR.Devices.Camera | Camera controller classes |