IC Imaging Control .NET

Filter Inspector

Filter Inspector

This example demonstrates how to use frame filters to perform basic image processing.

It shows, how to:

  • Enumerate the available frame filters.
  • Create frame filter instances.
  • Set a frame filter to do image processing on live video.

The source code for this sample program can be found under samples\C# *\Filter Inspector in your My Documents/IC Imaging Control 3.5 directory.

Using the Example

On the left side of the dialog box, there are two list boxes. The upper list box shows all filter modules that were found by IC Imaging Control. When you select one of the filter modules in this list, the lower list box displays the frame filters that can be loaded from the selected module.

When you click on one of the frame filters in the second list box, the filter is inserted in the Device Path. The live video displayed on the right side of the dialog box should now visualize the work of the frame filter.

You can click the Dialog... button to display the selected filter's property dialog.

If you select a new filter, the old filter will be removed and the new one will be used instead.

To see the untransformed image data from the video capture device, click the Remove button.


In the Form_Load event, ICImagingControl is initialized. If no device has been selected, ShowDeviceSettingsDialog is used to display a device selection dialog box. An important part here is to disable graphic overlay completely by setting ICImagingControl.OverlayBitmapPosition to PathPositions.None thus avoiding interference with the possible color formats of the frame filters.

if( !icImagingControl1.LoadShowSaveDeviceState("lastSelectedDeviceState.xml") ) { MessageBox.Show("No device was selected.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); return; } // Disable all overlays, so that they do not influence the // color format of the image stream. icImagingControl1.OverlayBitmapPosition = TIS.Imaging.PathPositions.None; // Start live mode. icImagingControl1.LiveStart();

Enumerating Available Frame Filters

To obtain a list of available frame filters, use FrameFilterInfo.FrameFilterInfos, which returns a collection of FrameFilterInfo objects.

Now we want to fill a list box with the names of the files in which the filters have been found. To do that, we look at each filter and add its module name to the list box, while filling ModulePaths with the module paths of the filters. The module names are not added, if the module path is already in the collection:

// Use a collection to save the full paths to the filter modules. modulePathCollection = new System.Collections.Specialized.StringCollection(); // For each filter info: // - Check if the filter's path is already in the module paths collection // - If not, add the module name to the filter module list box. foreach (TIS.Imaging.FrameFilterInfo ffi in TIS.Imaging.FrameFilterInfo.FrameFilterInfos) { if (modulePathCollection.IndexOf(ffi.ModulePath) < 0) { lstFrameFilterModules.Items.Add(ffi.ModuleName); modulePathCollection.Add(ffi.ModulePath); } }

In the event handler, which is called when the user selects a filter module name from the list box, a second list box is filled with the names of the filters in that module:

private void lstFrameFilterModules_SelectedIndexChanged(object sender, EventArgs e) { // Get the full path to the selected module from the ModulePaths collection. string selectedModulePath = modulePathCollection[lstFrameFilterModules.SelectedIndex]; lstFrameFilters.Items.Clear(); foreach (TIS.Imaging.FrameFilterInfo ffi in TIS.Imaging.FrameFilterInfo.FrameFilterInfos) { if (ffi.ModulePath == selectedModulePath) { lstFrameFilters.Items.Add(ffi); } } }

The loop fills a list box with all the frame filters that were loaded from the specified module. The index of the added filters in the original filter list (that was retrieved from FrameFilterInfo.FrameFilterInfos ) are stored in the list box's item data by setting ListBox.ItemData, thus allowing the filter info to be found when an end user clicks the item.

Creating Frame Filter Instances

When the user selects a filter from the filter list, the item data of the selected item is read, using ListBox.ItemData. Because we previously stored the filter's index in the list of available filters in the item data, we can use this number now to select the FrameFilterInfo in ICImagingControl.FrameFilterInfos:

// Get the selected FrameFilterInfo object TIS.Imaging.FrameFilterInfo ffi = (TIS.Imaging.FrameFilterInfo)lstFrameFilters.SelectedItem; if (ffi != null) { // Create the new FrameFilter instance. TIS.Imaging.FrameFilter newFrameFilter = TIS.Imaging.FrameFilter.Create(ffi);

The frame filter instance is created by calling ICImagingControl.FrameFilterCreate with the FrameFilterInfo object as its parameter.

Set the Frame Filter

To activate the frame filter, it has to be registered at the ICImagingControl object. The ICImagingControl.DeviceFrameFilters collection is cleared and the new filter is inserted. Device frame filters are used to transform the image data that comes from the video capture device.

// If live mode is active, stop. bool wasLive = icImagingControl1.LiveVideoRunning; if (wasLive) { icImagingControl1.LiveStop(); } // Set the new frame filter. icImagingControl1.DeviceFrameFilters.Clear(); icImagingControl1.DeviceFrameFilters.Add(newFrameFilter); // If live mode was active, restart. if (wasLive) { icImagingControl1.LiveStart(); }

Live mode has to be stopped in order to set a frame filter.

<< Programmer's Guide

Get in touch with us

About The Imaging Source

Established in 1990, The Imaging Source is one of the leading manufacturers of industrial cameras, video converters and embedded vision components for factory automation, quality assurance, medicine, science, security and a variety of other markets.

Our comprehensive range of cameras with USB 3.1, USB 3.0, USB 2.0, GigE, MIPI interfaces and other innovative machine vision products are renowned for their high quality and ability to meet the performance requirements of demanding applications.

ISO 9001:2015 certified MVTEC | Edge AI + Vision Alliance | EMVA

Contact us