This section contains a small example program showing how to configure a video capture device through the IC4_PROPERTY_MAP interface.
The article Accessing Device Properties explains the capabilities of the property interface in detail.
Open a Device
For demonstration purposes, we open the first available video capture device:
void ic4_devenum_unref(struct IC4_DEVICE_ENUM *pEnumerator)
Decreases the device enumerator's internal reference count by one.
bool ic4_devenum_update_device_list(struct IC4_DEVICE_ENUM *pEnumerator)
Searches for video capture devices and populates the enumerator's internal device list.
bool ic4_devenum_get_devinfo(const struct IC4_DEVICE_ENUM *pEnumerator, int index, struct IC4_DEVICE_INFO **ppInfo)
Returns a IC4_DEVICE_INFO object describing one of the discovered video capture devices.
bool ic4_devenum_create(struct IC4_DEVICE_ENUM **ppEnumerator)
Creates a new device enumerator.
void ic4_devinfo_unref(struct IC4_DEVICE_INFO *pInfo)
Decreases the device information's internal reference count by one.
bool ic4_grabber_create(struct IC4_GRABBER **ppGrabber)
Creates a new grabber.
bool ic4_grabber_device_open(struct IC4_GRABBER *pGrabber, struct IC4_DEVICE_INFO *dev)
Opens the video capture device specified by the passed IC4_DEVICE_INFO.
Represents an opened video capture device, allowing device configuration and stream setup.
Configure the Resolution
Next, we configure the device to output Mono8 data with a ROI of 640x480:
bool ic4_grabber_device_get_property_map(struct IC4_GRABBER *pGrabber, struct IC4_PROPERTY_MAP **ppPropertyMap)
Returns the property map for the currently opened video capture device.
#define IC4_PROPID_HEIGHT
Height of the image provided by the device (in pixels).
Definition C_PropertyConstants.h:699
#define IC4_PROPID_WIDTH
Width of the image provided by the device (in pixels).
Definition C_PropertyConstants.h:1099
bool ic4_propmap_set_value_int64(struct IC4_PROPERTY_MAP *map, const char *prop_name, int64_t value)
Set the value of a property with a known name to the passed integer value.
Represents the property interface of a component, usually a video capture device.
Define ROI Origin
Then, the origin of the ROI is moved to the top left corner of the sensor:
#define IC4_PROPID_OFFSET_AUTO_CENTER
Automatically adjust the values of OffsetX and OffsetY to select the center region of the sensor.
Definition C_PropertyConstants.h:849
#define IC4_PROPID_OFFSET_X
Horizontal offset from the origin to the region of interest (in pixels).
Definition C_PropertyConstants.h:854
#define IC4_PROPID_OFFSET_Y
Vertical offset from the origin to the region of interest (in pixels).
Definition C_PropertyConstants.h:859
bool ic4_propmap_set_value_string(struct IC4_PROPERTY_MAP *map, const char *prop_name, const char *value)
Set the value of a property with a known name to the passed string value.
Set an Exposure Time
Finally, we configure the device to a fixed exposure time of 5ms and enable automatic gain control:
#define IC4_PROPID_GAIN_AUTO
Sets the automatic gain control mode.
Definition C_PropertyConstants.h:649
#define IC4_PROPID_EXPOSURE_AUTO
Sets the automatic exposure mode when ExposureMode is Timed.
Definition C_PropertyConstants.h:544
#define IC4_PROPID_EXPOSURE_TIME
Sets the Exposure time when ExposureMode is Timed and ExposureAuto is Off.
Definition C_PropertyConstants.h:579
bool ic4_propmap_set_value_double(struct IC4_PROPERTY_MAP *map, const char *prop_name, double value)
Set the value of a property with a known name to the passed double value.
At the end of the program, references to objects have to be released:
void ic4_grabber_unref(struct IC4_GRABBER *pGrabber)
Decreases the grabber's internal reference count by one.
void ic4_propmap_unref(struct IC4_PROPERTY_MAP *map)
Decreases the property map's internal reference count by one.