Configuring video capture in osgART

From ARToolworks support library

Jump to: navigation, search

osgART > Configuring video capture in osgART

Introduction

Video capture in osgART is achieved through a video plugin. As well as the default plugin, which captures video using ARToolKit's libARvideo, library, a number of additional plugins are provided to allow capture directly from other sources which may not be supported by ARToolKit.

Most of the plugins support configuration to allow access to features of the underlying video hardware and/or capture library. Some of the plugins, such as osgart_video_ptgrey (a plugin for the flyCapture SDK by PointGrey) require use of configuration.

It is thus useful to know how to configure a video plugin, both to perform simple tasks like specifying parameters to ARToolKit's video capture library, as well as to be able to use some of the special video capture plugins.

Performing configuration of a video plugin from outside a program

Some of the video plugins (including the ARToolKit v2.x, ARToolKit v4.x and DSVideoLib) plugins are able to be configured without changing any sourcecode, either by using environment variables or configuration files.

See the page Configuring video capture in ARToolKit Professional for details.

Performing configuration of a video plugin from within your code

A video plugin should typically be configured after the plugin is initialised and before the video stream is opened.

  • Pre-load the plugin, then init the plugin via the plugin manager.
	// Preload the video, exiting in case of error.
	if (!osgART::PluginManager::instance()->load("osgart_video_artoolkit")) exit(-1);
 
	// Initialise the video plugin.
	// Check if an instance of the video stream could be started, exiting if not.
	osg::ref_ptr<osgART::GenericVideo> video = 
		dynamic_cast<osgART::GenericVideo*>(osgART::PluginManager::instance()->get("video_artoolkit"));
	if (!video.valid()) {   
		// Without video an AR application can not work. Quit if none found.
		osg::notify(osg::FATAL) << "Could not initialize video plugin!" << std::endl;
		exit(-1);
	}
  • Get a pointer to the plugin's VideoConfiguration
	// found video - configure now
	osgART::VideoConfiguration* _config = video->getVideoConfiguration();
  • Set the fields in the config to the desired values. Possible fields include:
    • deviceconfig - a string, holding text-based configuration understood by the plugin. E.g., the osgart_video_artoolkit and osgart_video_artoolkit4 plugins are configured with this string. See Configuring_video_capture_in_ARToolKit_Professional for more info.
    • id, width, height, framerate, type - these parameters form a group through which some plugins are configured, e.g. osgart_video_ptgrey. See the header "osgART/videoConfig" for details of what you can put into these fields.
	// Use any existing configuration.
	if (_config) 
	{
 
		if (argc > 1) {
			_config->deviceconfig = argv[1];
		} else  {
			_config->deviceconfig = "configuration string goes here";
		}
 
		// Another example:
		//_config->deviceconfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
		//	"<dsvl_input><avi_file use_reference_clock=\"true\" file_name=\"Data\\MyVideo.avi\" loop_avi=\"true\" render_secondary=\"true\">"
		//	"<pixel_format><RGB32/></pixel_format></avi_file></dsvl_input>";
	}

Once the video is configured, open the video - the changed config will be used. If the video is open and you wish to change the config, stop and close it before proceeding as above (skipping the plugin loading and initialising).

Personal tools