MontiVision Smart ActiveX Control for easy DirectShow
Development
Loading, saving and
configuring a filter graph
MontiVision Project Files (*.mvp) contain
all the information necessary to build a fully functional filter
graph configuration. The first step to take when using
the MV Smart
Control for a vision application is to create a working
"MVP" project file using the MV Worbench. Having
created a fully functional graph in the MV Worbenchand saved it to an
MVP file, you would be ready to load the project into your vision
application. To do either load or save an MVP file, use the MV
Smart Control's IMVSCFilterGraph interface and call
either the LoadConfig() or the SaveConfig() method. The
UnloadConfig() method removes the filter graph configuration from
the control and frees all resources, for example capture
sources.
Once you have loaded the configuration,
you can control it's running state with the Start(), Stop() and
Pause() methods available from the IMVSCFilterGraph
interface. You also have full access to the filter graph
with the FilterGraphManager property from IMVSCFilterGraph which contains a
pointer to the IUnknown interface from the DirectShow filter
graph manager. Use this interface to get the DirectShow
interfaces from the filter graph manager (e.g. IFilterGraph2 or
IMediaSeeking). To get the IUnknown interface from a
filter, call the GetFilter() method from IMVSCFilterGraph with the filter
name from the filter. This method is useful for retrieving a
configuration interface from a DirectShow filter.
The last property from IMVSCFilterGraph is useful for
debugging purposes. With the ExportFilterGraph property
you can enable the export filter graph function from the MV Smart
Control. If this property is enabled the MV Workbench will make
the instantiated filter graph visible to the "Connect to Graph"
command from the file menu.
Displaying a video stream
The window from the control can be used to
display the video stream from a video renderer. If your filter
graph configuration has more than one video renderer, use the
RendererFilter property in the IMVSCVideoWindow interface to
attach a video renderer to the control window. The IMVSCVideoWindow interface contains
properties such as the UseAspectRatio,
UseOriginalSize and Visible property. The
VideoXResolution and VideoYResolution properties
contains the original video stream resolution. To display the video
without stretching set the control window size to the video
resolution or use the UseOriginalSize property.
The IMVSCVideoWindow interface contains
the MessageDrain property. The message drain is a
window handle that receives all input device messages (e.g.
WM_CHAR) from the video window.
The MontiVision Smart
Control also supports full-screen display of video. The
interface that caters for this is IMVSCFullScreen, which contains three
properties: FullScreen, MonitorCount and
Monitor. The MonitorCount property returns the
number of available monitors while the Monitor property
returns the current monitor used for the full-screen function. Set
the FullScreen property to enable the full-screen
feature.
Slave video
window function
In some cases a vision application contains more than one video
stream. To display all video streams in such an application, you
will need to include one MontiVision Smart Control for
each video stream. Use only one of these controls to load and
control the filter graph (we will refer to this as the master
control). The other controls are used as "slave video window
controls". In such a scenario, call the SetVideoRenderer
method from the IMVSCVideoWindow interface to
configure these slave controls. The SetVideoRenderer
method will need the filter graph manager and the video renderer's
filter name as parameters. These can be retrieved from the
master control by using the FilterGraphManager
property of the IMVSCFilterGraph interface.
Changing the
video source
A well-known caveat with DirectShow application development is
the support for different video sources within one filter
configuration. The MontiVision Smart
Control solves this problem with the
IMVSCSetSourceFilter interface
which contains only one method: SetSourceFilter . This
method replaces a video source filter, needing only the
"Display Name" from the new video source and the name of the
existing filter in the filter graph configuration. The "Display
Name" from the new source filter describes in detail the video
device. You can get the display name from the MV
VideoSourceComboBox.
Not only is it now possible to change the
video source, but it is also possible before or after loading a
configuration file. It is recommended however that you
reload a configuration after changing the source filter.
If you change the device within a loaded configuration it is
possible, that the MV Smart Control can't rebuild the filter
graph.
Changing the
video format
A video source can support many video formats. The
MontiVision Smart Control
exposes the IMVSCSetupVideoStream interface
for purposes of making such changes.
- To retrieve the video stream colour format (e.g.
RGB24) use the GetVideoFormatCount
and GetVideoFormatLabel methods.
- To retrieve the video stream resolution use the
GetVideoSizeInfoCount and
GetVideoSizeInfo.
- To set a new format call SetVideoFormat. The
GetCurrentVideoFormat method returns the currently used
video format.
You can also use the MV
VideoFormatComboBox and MV VideoSizeComboBox
the facilitate changes to the video format.
It is not recommend that you change the video stream colour
format because in some cases the MV Smart control will not be able
to rebuild the filter graph after such a change. It is rather
recommended that you allow DirectShow to select the best colour
format from the device.
Selecting
alternative inputs
Some capture devices have more than one video input. The
IMVSCSelectInput interface
from the MV Smart Control controls selection of these video inputs.
You can use the MV
SelectInputComboBox to select a video
input. The other way is to use the methods from IMVSCSelectInput. Start with
IsAvailable to check if a video device has more than one
video inputs. Retieve the number of inputs with InputCount
and enumerate them GetInputLabel. The
CurrentConnection method returns the currently connected
video input. To proceed with selecting a specific video input call
the Connect method.
Changing files
for File Sink and File Source filters
Filter graph configurations with file sink/source filter contain
the path to the used file. To change these paths, the MV Smart
Control exposes the IMVSCSetFile
interface. For the file sink filter use the SetSinkFile
and GetSinkFile methods and for the file source filter use
the SetSourceFile and GetSourceFile methods. You
can call the methods before or after loading a filter
configuration. However, it is recommend that you set
the filter to valid paths before you load a filter
configuration. If the a file source/sink filter uses a invalid path
the MV Smart Control will not be able to connect to these
filters.
Changing the folder for
the MV
Batch Image File Source Filter
You can change the folder used by
a MV
Batch Image File Source Filter in the same way as you
would the files for file sink/source filters. The IMVSCSetFile contains a
SetBatchFolder and GetBatchFolder method to allow
you to change the folder.
Open property dialogs from direct
show filters
Most of the DirectShow Filters and
all MontiVision
Filters contains property pages to configure filter
parameters. The IMVSCFilterProperties interface
from the MontiVision Smart
Control
contains some methods to enumerate these filters and displays
dialogs with the filter property pages. To to enumerate the filter
with property pages call the GetPropertyPageName method.
Open a dialog with the ShowProperties method. If you want
to close a dialog call the CloseProperties method. It is
not necessary to explicitly
call CloseProperties because all dialogs are
closed when the "OK" dialog button is pressed or if the filter
configuration is unloaded.
Filter graph
reference clock control
In some cases it is necessary to disable the reference clock in
a filter graph. This might be necessary for example, if you wanted
to process each frame of a video file. With the IMVSCClock interface you call setup the
reference clock from a filter graph. Call the Disable
method to disable the reference clock, and use SetDefault
to return to using the default cock.
Handle Input Events from the
Video Window
To handle input events from the video window such as mouse
button clicks, set the IMVSCVideoWindow::EnableVideoWindowEvents property.
This will allow you to handle the input events with the
MV Smart Control Event
Interface.
Log
function
For debugging purposes the MontiVision Smart Control contains
the IMVSCLog interface. It has two properties. The
Enable property enables the log function and the
Level property contains the minimum level for log
messages. If the log function is enabled the MontiVision Smart Control calls
the LogMessage method from the _IMVSmartControlEvents interface
if a message is greater than or equal to the Level
property.
Video Source Configuration
The IMVSCCameraControl interface
contains methods to configure parameters such as contrast or
brightness for a video source device. Use the methods in your
application to change device parameters. The interface contains
also methods to load and save all parameter from a video device
into the registry.
Handle Events from MontiVision Imaging
Filter
Lots of the MontiVision
Imaging Filters fires events. The MontiVision Smart Control
propagates these events to the application. Event
notification is enabled with the IMVSCFilterEvents::Enable
method. The _IMVSmartControlEvents::FilterEvent method
is called on every event from an enabled MontiVision Imaging Filter.
Use
Media Seeking on Video Files
To navigate within a movie file the
MontiVision Smart
Control provides the IMVSCMediaSeeking interface. It is
based on the IMediaSeeking interface from DirectShow. To use this
interface the MontiVision
Development Kit contains the MV
SeekingSlider Control.
Save Filter Parameter into the
Registry
Most of the MontiVision
Imaging Filters can load/save there parameter from/into
the registry. The IMVSCFilterData interface from the
MontiVision Smart
Control provides methodd to load and save filter parameter
for a filter from a filter configuration.
Get Video
Processing Information
To obtain certain information about the
video processing (such as the frame rate) the MontiVision Smart Control
provides the IMVSCQualityProperties
interface.
|