With frame filters, a versatile and powerful way to manipulate image data is introduced. Besides other features, frame filters can be used to change or convert the video format of the image stream, implement image processing and control which frames are processed.
In contrast to other DirectShow libraries, the frame filters of IC Imaging Control are not DirectShow filters. But they are executed in the context of a DirectShow thread that processes the image stream. This saves the programmer the hassle of creating a DirectShow filter module, registering it and defining interfaces for the parameters. Frame filters are implemented in C++ as part of a filter module. They are loaded on demand by the OCX from the module and may be inserted at three locations in the image stream. Frame filters are basically far easier to implement and to use as DirectShow filters by providing the same performance with regard to image processing. C# allows frame filters to be implemented as part of a program. In order to create a frame filter module, C++ has to be used.
Frame filters open the door to a vast number of new IC Imaging Control based applications. In order to show you what is possible with this new concept, we discuss categories of tasks that can be implemented with frames filters. For some of these tasks, frame filters are shipped with IC Imaging Control.
As described earlier, frame filters can be created directly in an application or loaded from a filter module. IC Imaging Control provides some filters in the module stdfilters.ftf. In order to obtain a list of the frame filters in all currently available filter modules, examine the FrameFilterInfo.FrameFilterInfos collection. With the FrameFilterInfo.FrameFilterPath property, an additional path for filter modules may be specified. A call to FrameFilter.Create creates an instance of a filter that was selected from the list of available filters. Now that we have a frame filter instance, we can insert it at three different locations in the image stream:
Please note that the same instance of a frame filter should not be used at more than one place in the image stream because its internal state may get inconsistent, especially if FrameFilterImpl.NotifyStart and FrameFilterImpl.NotifyStop are used. If it is necessary to insert the same filter at more than one location in the image stream, different instances of the frame filter should be used.
The internal data of a frame filter can be accessed through the parameter interface. With the methods FrameFilter.SetIntParameter, FrameFilter.GetIntParameter, FrameFilter.SetBoolParameter, FrameFilter.GetBoolParameter, FrameFilter.SetStringParameter, FrameFilter.GetStringParameter, FrameFilter.SetFloatParameter, FrameFilter.GetFloatParameter, the following basic data types can be read from or written to the filter: bool, long, float and string. A block of binary data can be exchanged with a frame filter with the FrameFilter.SetDataParameter and FrameFilter.GetDataParameter methods. Since the transform method of a filter is executed within a DirectShow thread, it is very important to synchronize external and internal access to the filter's data. Therefore, it is very important that a sequence of calls to the four methods mentioned above is preceded by a call to FrameFilter.BeginParameterTransfer and is followed by a call to FrameFilter.EndParameterTransfer:
If a frame filter is used by generic applications, such as the Filter Inspector, a dialog should be implemented that allows the parameters to be altered interactively. A frame filter indicates that it provides a parameter dialog by returning true in the method FrameFilter.HasDialog. The dialog should be displayed when the method FrameFilter.ShowDialog is called.
To serialize the settings of a frame filter, use the FrameFilter.FilterData property. To save the settings directly to a file, use the FrameFilter.SaveFilterData and FrameFilter.LoadFilterData methods.