DirectShow Sample Application: GDI Video Overlay

The LiveDraw sample demonstrates how to draw onto a video stream using standard GDI functions.

This and other sample applications can be found in the MV Development Kit installation directory.

Use this application as a starting point for your own live video overlay applications.

 

Filter Graph Summary

The application uses the following filter graph to draw a line onto the live video stream. It utilizes  MV GDI Overlay Filter for the actual drawing.

LiveDraw Sample Filter Graph

The Application

This sample application uses a MontiVision Smart Control to load and control the filter configuration and to display the live video stream. It uses the  MV VideoSourceComboBox, MV VideoSizeComboBox and MV SelectInputComboBox controls to select and configure the video source.

You have the option to choose between two overlay modes. Transparent background draws a white line while the second mode considers the given alpha value. Unless the persistence checkbox is checked, the DC surface will be deleted before a new line is drawn.

To determine the start and end points of the line to be drawn onto the video stream,  the sample obtains mouse click (input) events from the video window. There are two ways to implement this.

1. Enable the input events of the video window using the IMVSCVideoWindow::EnableVideoWindowEvents property and handle the video window input events of the _IMVSmartControlEvents  event interface. This method is used by the Visual Basic LiveDraw example.

2. Another way is to use the  IMVSCVideoWindow::MessageDrain  property to set a window as the message sink for the input events of the video window. This method is used by the Visual C++ sample. The window used as sink should only be used for this task because the window receives the window messages with video window coordinates. This can result in strange behaviour if the window contains other controls.