# DirectShow Transform Filter AppWizard

 Developed by Yunqiang (Charles) Chen

chenyq AT ifp.uiuc.edu

 

Sept. 6, 2001

This is a Visual C++ 6.0 appwizard. It will help to create default transform (or In-Place Transform) filter for video processing using DirectShow (part of Microsoft DirectX); It can be easily changed to do audio processing as well. To use the wizard, download the (DShowFilterWiz.awx and DShowFilterWiz.HLP) and copy them to C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Template. You can select "DirectShow Filter AppWizard" when you new a project in VC 6.0. Specify the project name and click "ok" to generate the project.
 

What’s this AppWizard for:

This is an app-wizard for writing DirectShow Transform Filters (including in-place transform filter). ‘Transform filter’ transform the media data that comes into their input pins and send the transformed data out their output pins. Transform filters can be used to compress and decompress data, to split audio and visual data, or to apply effects, such as contrast or warbling, to media data. Microsoft® DirectShow® contains several sample transform filters that perform different kinds of transformations.

 

This AppWizard creates a default filter to grab the image frames (RGB24 or RGB32 uncompressed image data) and apply some special effect (XOR) to the media data. To implement your own filter, you could just create a project using this ‘DirectShow Transform Filter AppWizard’ and change the code according your own task.

 

Before using this AppWizard:

It is necessary to install the DirectX SDK 8.0 or later (can be downloaded from Microsoft Web) before compiling and using the filter. Several notes about installing the DirectX:

 

  1. Install DirectX: 
    Add DirectX SDK header and lib dir (e.g. DXSDK\include and DXSDK\lib) into the VC options->Directories. (Typically, the setup wizard of DirectX will do this.).
     
  2. DirectShow Baseclass: 
    Compile the DXSDK\samples\Multimedia\DirectShow\BaseClasses\BaseClasses.dsw to generate the essential lib files (Debug version and Release version); It is needed for building the generated project.

  

Generate a DirectShow Filter:

To generate a default DirectShow Transform Filter, use “VC++ 6.0 -> File -> New” to new a project using the ‘DirectShow Transform Filter AppWizard’. A dialog asks the following questions to decide how to generating the files:


 

  1. Do you want to use the In-Place Transform filter or use a Transform Filter?
    Transform filter will copy the media data from input pin to output pin;
    In-Place Transform filter does not copy the data and hence saves the cost of copying data. All the process is being done in-place. But looks to me it is more buggy when renegotiate the media type between the input pin and output pin and sometimes may cause significant slow down. I hope later DirectX will correct these bugs.
     
  2. Do you want to use MFC classes (CRect, CList, CFile, etc.) in the filter?
    By default, I will not use MFC classes in a Filter. But you could check this box to include the MFC in case you want to use some classes in the MFC.

     
  3. What color format you need?
    What kind of color images you can handle in the filter? There are RGB24, RGB32, …. They are stored differently in the memory, if you want to handle different format, you have to deal with them carefully. The color image format can be changed later by editing the generated code in CMyFilter:: canPerformTransform(). If the required color format is not the same as the video source, Color Space Converter Filter which is shipped with DirectX can be used to change the color format of the source to the required format.
     
  4. Automatically register the filter to the system
    Tell the appwizard if you want the filter to be registered to the system (Run ‘regsvr32 MyFilter.ax’ automatically) after it’s successfully built.)
     
  5. Where is the DirectX SDK installed?
    To compile the project, you need DirectX SDK. The default setup path is c:\DXSDK\. But it maybe installed somewhere else. Please specify it so that the wizard knows where to find the header files and libraries. (You should specify it with ‘\’ at the end to indicate it is a directory, e.g. ‘c:\DXSDK\’)

 

The wizard will then generate a project based on the specifications. It automatically generate new GUIDs for the filters. There is no need to worry about the GUIDs.

 

Write you own processing codes:

After the filter project is generated, you could add your own processing code to process the image data (e.g. apply some special effect, analysis the data, etc.)

 

  1. Special Processing: The image data can be obtained in the CMyFilter::Transform(IMediaSample *pMediaSample). You can analysis or overlay graphics onto the image frames in this function.
     
  2. Control Filter Behavior: To control the filter, you could implement the CMyFilterProp class to provide the setup dialog box for user to control the filter;

 

Use DirectShow Transform Filter

After the filter is implemented, you can register the filter by using:

regsvr32 MyFilter.ax

and then begin to use it.

 

Use the filter in GraphEdt: (shipped with DirectX SDK 8.0) to apply you own process to the video data.

  1. Run GraphEdt.exe (in c:/DXSDK/bin/DxUtils/)
  2. Choose menu "Graph"->"Insert Filter" to insert the filter you just registered (it should be in "DirectShow Filters" and named as ‘MyFilter Filter’)
  3. Choose menu "File"->"Render Media File" to process a video file or insert the "video capture source filter" (if you have cameras on your machine) and render output pin. A typical capturing graph looks like following. You could also build such graphs in your own applications.


 

  1. Play the graph and you will see the output video being XORed
  2. To control the filter, right click on your filter and choose "properties" to setup the filter. The default property page let you to enable/diable the XOR operation;

 

Use the filter in your own App: You could also write your own program to manage the filter graph and process the video data. A sample program that use a transform filter to do tracking and overlay the tracking results on the image is shown as follows. The video is rendered into the app window by the DirectX Video Render Filter:

  



# HIDD_CUSTOM1