Imaging Control 4 C++ Library  1.3.0
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);

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

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

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
ic4::PropId::ExposureTime
constexpr PropIdFloat ExposureTime
Sets the Exposure time when ExposureMode is Timed and ExposureAuto is Off.
Definition: PropertyConstants.h:580
ic4::PropId::OffsetY
constexpr PropIdInteger OffsetY
Vertical offset from the origin to the region of interest (in pixels).
Definition: PropertyConstants.h:860
ic4::PropId::Width
constexpr PropIdInteger Width
Width of the image provided by the device (in pixels).
Definition: PropertyConstants.h:1100
ic4::PropId::GainAuto
constexpr PropIdEnumeration GainAuto
Sets the automatic gain control mode.
Definition: PropertyConstants.h:650
ic4::PropId::Height
constexpr PropIdInteger Height
Height of the image provided by the device (in pixels).
Definition: PropertyConstants.h:700
ic4::PropertyMap::setValue
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:1982
ic4::PropId::PixelFormat
constexpr PropIdEnumeration PixelFormat
Format of the pixels provided by the device.
Definition: PropertyConstants.h:870
ic4::PropId::OffsetAutoCenter
constexpr PropIdEnumeration OffsetAutoCenter
Automatically adjust the values of OffsetX and OffsetY to select the center region of the sensor.
Definition: PropertyConstants.h:850
ic4::Grabber::deviceOpen
bool deviceOpen(const DeviceInfo &dev, Error &err=Error::Default())
Opens the video capture device specified by the passed device information object.
Definition: Grabber.h:214
ic4::DeviceEnum::enumDevices
static std::vector< DeviceInfo > enumDevices(Error &err=Error::Default())
Get a list of the devices currently attached to the system.
Definition: DeviceEnum.h:446
ic4::PropId::OffsetX
constexpr PropIdInteger OffsetX
Horizontal offset from the origin to the region of interest (in pixels).
Definition: PropertyConstants.h:855
ic4::Grabber
Represents an opened video capture device, allowing device configuration and stream setup.
Definition: Grabber.h:81
ic4::Grabber::devicePropertyMap
PropertyMap devicePropertyMap(Error &err=Error::Default()) const
Returns the property map for the currently opened video capture device.
Definition: Grabber.h:628
ic4::PropId::ExposureAuto
constexpr PropIdEnumeration ExposureAuto
Sets the automatic exposure mode when ExposureMode is Timed.
Definition: PropertyConstants.h:545
ic4::PixelFormat::Mono8
@ Mono8
Monochrome 8-bit.