Enumeration Properties of IC 4

From The Imaging Source Knowledgebase
Jump to navigation Jump to search

Enumeration properties are properties that expect and return a string and provide a list of valid strings for selection. For example, the pixel format of a camera can contain "Mono8", "Mono16", "BayerRG8" etc. The DevicePropertyMap.FindEnumeration() function is used to obtain the selection list. This receives the name of the property as a parameter, e.g. "PixelFormat", "BalanceWhiteMode" etc. The function returns an enumeration.

C#

var formats = grabber.DevicePropertyMap.FindEnumeration("PixelFormat");
foreach (var format in formats.Entries)
{
    Console.WriteLine($"{format.Name}");
}

Python:

formats = grabber.device_property_map.find_enumeration(ic4.PropId.PIXEL_FORMAT)
for i,format in enumerate(formats.entries):
        print(f"{i} : {format.name}")

The enumeration properties are set with the DevicePropertyMap.SetValue() function: grabber.DevicePropertyMap.SetValue("BalanceWhiteMode", "WhiteBalanceMode_Temperature"); Or, if there is a user selection and a selected index:

C#:

grabber.DevicePropertyMap.SetValue("BalanceWhiteMode", WhiteBalanceModes.Entries.ToArray()[1].Name);

Python:

grabber.device_property_map.set_value(ic4.PropId.PIXEL_FORMAT, formats.entries[selected_index].name )


The C/C++ code is similar.

For further questions, please use our contact form