Imaging Control 4 C++ Library 1.0.0
Loading...
Searching...
No Matches
Configuring a Video Capture Device

This section contains a small example program showing how to configure a video capture device through the ic4::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
ic4::Grabber grabber;
// Open the first available video capture device
auto info = ic4::DeviceEnum::enumDevices().front();
grabber.deviceOpen(info);
static std::vector< DeviceInfo > enumDevices(Error &err=Error::Default())
Get a list of the devices currently attached to the system.
Definition DeviceEnum.h:446
Represents an opened video capture device, allowing device configuration and stream setup.
Definition Grabber.h:82
bool deviceOpen(const DeviceInfo &dev, Error &err=Error::Default())
Opens the video capture device specified by the passed device information object.
Definition Grabber.h:147

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
// Set the resolution to 640x480
PropertyMap devicePropertyMap(Error &err=Error::Default()) const
Returns the property map for the currently opened video capture device.
Definition Grabber.h:561
bool setValue(const char *integer_name, int64_t value, Error &err=Error::Default())
Set the value of a property with a known name to the passed integer value.
Definition Properties.h:1990
constexpr PropIdEnumeration PixelFormat
Format of the pixels provided by the device.
Definition PropertyConstants.h:870
constexpr PropIdInteger Height
Height of the image provided by the device (in pixels).
Definition PropertyConstants.h:700
constexpr PropIdInteger Width
Width of the image provided by the device (in pixels).
Definition PropertyConstants.h:1100
@ Mono8
Monochrome 8-bit.

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
constexpr PropIdInteger OffsetX
Horizontal offset from the origin to the region of interest (in pixels).
Definition PropertyConstants.h:855
constexpr PropIdEnumeration OffsetAutoCenter
Automatically adjust the values of OffsetX and OffsetY to select the center region of the sensor.
Definition PropertyConstants.h:850
constexpr PropIdInteger OffsetY
Vertical offset from the origin to the region of interest (in pixels).
Definition PropertyConstants.h:860

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)
// Enable GainAuto
constexpr PropIdEnumeration ExposureAuto
Sets the automatic exposure mode when ExposureMode is Timed.
Definition PropertyConstants.h:545
constexpr PropIdFloat ExposureTime
Sets the Exposure time when ExposureMode is Timed and ExposureAuto is Off.
Definition PropertyConstants.h:580
constexpr PropIdEnumeration GainAuto
Sets the automatic gain control mode.
Definition PropertyConstants.h:650