Demo: GPU shader Sobel filter and video capture with Media Foundation Capture Engine API

Back to some experiments…

The current video capture API in Windows is Media Foundation Capture Engine API (AKA IMFCaptureEngine and mfcaptureengine.h). Media Foundation is layered: you can work at lower level with video capture Media Sources, but if you don’t want to go into details you have the Capture Engine.

The application continues a good old CaptureEngineVideoCapture sample from Windows Classic Samples, and adds an effect in form factor of Media Foundation Transform to the engine.

One of the unobvious aspects is that video stream goes with data backed in video memory by default. Hence, the effect would preferrably handle the stream on associated Direct3D 11 device.

The effect here is a HLSL equivalent of Webcam edge glow shadertoy, and processes the video from webcamera on GPU, via shader implementing Sobel operator. The data does not leave video memory and continues its travel along capture engine to preview visualization.

The shader code can be looked up at in the executable resources, it is compiled on runtime.

Leave a Reply