Demistifying DSVL Configuration

directx-logoIn my previous post I just mentioned how we can use ARToolkit in conjunction with a 3D rendering engine. The camera connection was made by the ARToolkit via DSVL (DirectShow Video Library) . As I promised, through this post, I’ll expose how we can configure DSVL with its supported parameters.

DSVL is a wrapper for DirectShow which in turn is a part of DirectX. We all know that DirectX is the prominent media framework used in windows platforms. Other than DirectShow, Direct3D and DirectSound also come under the brotherhood of DirectX. So what is the specialty of DirectShow? In computers data can be generated in many places, such as file system, network, TV cards or video cameras etc. And data which is produced at each of these locations take many formats. Therefore front-end applications have to explicitly communicate with these underlying data sources and deal with its formats. Obviously this would be pretty cumbersome and overwhelmingly incompatible with different hardware devices. This is where DirectShow comes in to handy. It synchronizes and unifies all the communication flow between our application and the underlying hardware. In particular DirectShow talks directly with the camera drivers, capture card drivers etc… and provide feedback for the user application. This is the simplest way we can understand it, but for more details go here http://msdn.microsoft.com/en-us/library/windows/desktop/dd375454(v=vs.85).aspx .

Coming back to ARToolkit, our intention is to make a connection to the camera and capture video frames. One way to achieve this would be to install the DirectShow SDK and use its API’s. This is what exactly being done by DSVL. If we look at the ARToolkit installation folder and go to lib\SRC\VideoWin32DirectShow we can find a file called videoWin32DirectShow.cpp. DSVL was referenced in this file and all the camera communication matters (opening the camera, closing the camera, etc…) are implemented in here. All of the functions pertaining to camera handling were done with the courtesy of DSVL.

DSVL requires a configuration string in XML order to make a successful connection to the camera. We can either provide this XML string in code or in a separate XML file. The latter is preferred as we don’t need to compile all the time we change configuration.  It’s here in this XML string that we provide configuration parameters like width, height, frame rate etc. But we must ensure the correct parameter names. Let’s see the following.

dsvlxml

Given above is a sample XML file that specifies the configuration to be used by DSVL. The structure is as follows.

  • The root element is <dsvl_input>.
  • Under that it has a child element <camera>.
  • <camera> tag possesses some attributes namely, show_format_dialog, friendly_name, frame_width, and frame height.
  • When the show_format_dialog is set to true, then a dialog box appears asking the camera width, height, and frame rate of the video whenever we run the application.
  • We can have fixed values for frame width and frame height by setting the frame_width & frame_height attributes respectively.
  • <camera> tag contains a child element named <pixel_format>. Here it’s set to <RGB32>. The video can be inverted vertically or horizontally by setting flip_v & flip_h. 

Once we download DSVL libraries here (http://sourceforge.net/projects/dsvideolib/files/) we can go to its extracted location. In my computer it’s C:\ARToolKit\DSVL. Here we can find a schema file named DsVideoLib.xsd. Open this file you’ll get all the necessary parameters that can be included in your XML configuration string.

It’s better to open this in Visual Studio and with the XML Schema Explorer tab, we can get the parameter names.

XML_Schema

Expand each of the nodes and you’ll get additional parameters for your video configuration. For instance, expand the pixel_format node you’ll get following options.

pixel_format

This is how you can set additional parameters in DSVL video configuration for ARToolkit or any other application (as long as it uses DSVL). It’s probably better to be aware about this DsVideoLib.xsd when there are different types of cameras involved in your application. So you can test the mode that works with each camera. Thanks and any comments are welcome.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s