Configuring a Video Capture Device

This section contains a small example program showing how to configure a video capture device through the PropertyMap interface.

The article Accessing Device Properties explains the capabilities of the property classes in detail.

Open a Device

For demonstration purposes, we open the first available video capture device:

// Create a grabber object
var grabber = new ic4.Grabber();

// Open the first available video capture device
var firstDevInfo = ic4.DeviceEnum.Devices.First();
grabber.DeviceOpen(firstDevInfo);

Configure the Resolution

Next, we configure the device to output Mono8 data with a ROI of 640x480:

// Configure the device to output images in the Mono8 pixel format grabber.DevicePropertyMap.SetValue(ic4.PropId.PixelFormat, ic4.PixelFormat.Mono8);

// Set the resolution to 640x480
grabber.DevicePropertyMap.SetValue(ic4.PropId.Width, 640);
grabber.DevicePropertyMap.SetValue(ic4.PropId.Height, 480);

Define ROI Origin

Then, the origin of the ROI is moved to the top left corner of the sensor:

// Set the origin of the ROI to the top-left corner of the sensor
grabber.DevicePropertyMap.SetValue(ic4.PropId.OffsetAutoCenter, "Off");
grabber.DevicePropertyMap.SetValue(ic4.PropId.OffsetX, 0);
grabber.DevicePropertyMap.SetValue(ic4.PropId.OffsetY, 0);

Set an Exposure Time

Finally, we configure the device to a fixed exposure time of 5ms and enable automatic gain control:

// Configure the exposure time to 5ms (5000µs)
grabber.DevicePropertyMap.SetValue(ic4.PropId.ExposureAuto, "Off");
grabber.DevicePropertyMap.SetValue(ic4.PropId.ExposureTime, 5000.0);

// Enable GainAuto
grabber.DevicePropertyMap.SetValue(ic4.PropId.GainAuto, "Continuous");