DirectShow with OpenCV


Tutorial: (old)

Using OpenCV with Visual C++ 6 and Microsoft's DirectShow (external non-wiki link)


Where to download DirectShow?

The DirectShow development tools and documentation are distributed as part of the Microsoft Platform SDK.

The Platform SDK can be downloaded here.

After you download the Platform SDK, go to the Samples\Multimedia\DirectShow\BaseClasses folder and compile the BaseClasses solution to generate the lib files, which you need in order to use DirectShow in your application.

(After you compile, strmbasd.lib will be generated inside the Debug folder, which you can use in your applications... Note that the lib file is the debug version only..)

Direct X (may also be needed)

Go to Microsoft DirectX Downloads, and download the most recent DirectX SDK (currently June 2006)

Microsoft DirectShow Documentation:

Microsoft Developer Network: DirectShow

Library providing simple frame grab interface:

You can use the video input library at http://muonics.net/school/spring05/videoInput/ to avoid the messiness of dealing with DirectShow. It even works for direct capture to the imageData field of an IPL image, though I found that the result was upsidedown and had red and blue switched.

Author of videoInput's note: New version out - lots of new stuff. No need to switch red and blue as you can specify which order you want when you grab the pixels. Maybe Paramesh could update his sample code bellow for the new version?

Sample Code:

#include "videoInput.h"

videoInput::listDevices();

videoInput* VI = new videoInput();

VI->setup(0);

VI->grabFrame(0, (unsigned char*)img1->imageData);

//Result of above was upside-down and had red/blue inverted, so I do something

//like the below (swapRedBlue is my own function)

swapRedBlue(img1);

cvConvertImage(img1, img2, CV_CVTIMG_FLIP);

===========================================

Regards, {OK} Paramesh.

DirectShow (last edited 2008-05-28 14:02:25 by localhost)

SourceForge.net Logo