12 #include "PlusConfigure.h" 18 #include "vtkSmartPointer.h" 19 #include "vtkTimerLog.h" 20 #include "vtkXMLUtilities.h" 21 #include "vtksys/CommandLineArguments.hxx" 22 #include "vtksys/SystemTools.hxx" 24 int main(
int argc,
char **argv)
26 std::string inputConfigFileName;
27 double inputAcqTimeLength(60);
28 std::string outputVideoBufferSequenceFileName(
"VideoBufferMetafile");
30 int verboseLevel=vtkPlusLogger::LOG_LEVEL_UNDEFINED;
32 vtksys::CommandLineArguments args;
33 args.Initialize(argc, argv);
35 args.AddArgument(
"--config-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputConfigFileName,
"Name of the input configuration file.");
36 args.AddArgument(
"--acq-time-length", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputAcqTimeLength,
"Length of acquisition time in seconds (Default: 60s)");
37 args.AddArgument(
"--output-video-buffer-seq-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &outputVideoBufferSequenceFileName,
"Filename of the output video bufffer sequence metafile (Default: VideoBufferMetafile)");
38 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level (1=error only, 2=warning, 3=info, 4=debug, 5=trace)");
42 std::cerr <<
"Problem parsing arguments" << std::endl;
43 std::cout <<
"Help: " << args.GetHelp() << std::endl;
49 if (inputConfigFileName.empty())
51 std::cerr <<
"config-file is required" << std::endl;
56 vtkSmartPointer<vtkXMLDataElement> configRootElement = vtkSmartPointer<vtkXMLDataElement>::New();
59 LOG_ERROR(
"Unable to read configuration from file " << inputConfigFileName.c_str());
63 vtkSmartPointer<vtkPlusDataCollector> dataCollector = vtkSmartPointer<vtkPlusDataCollector>::New();
64 dataCollector->ReadConfiguration( configRootElement );
65 dataCollector->Connect();
66 dataCollector->Start();
68 const double acqStartTime = vtkTimerLog::GetUniversalTime();
70 while ( acqStartTime + inputAcqTimeLength > vtkTimerLog::GetUniversalTime() )
72 LOG_INFO( acqStartTime + inputAcqTimeLength - vtkTimerLog::GetUniversalTime() <<
" seconds left..." );
73 vtksys::SystemTools::Delay(1000);
77 LOG_INFO(
"Copy video buffer");
80 if( dataCollector->GetDevice(device,
"VideoDevice") !=
PLUS_SUCCESS )
82 LOG_ERROR(
"Unable to locate the device with Id=\"SomeVideoSource\". Check config file.");
91 LOG_INFO(
"write video buffer to " << outputVideoBufferSequenceFileName);
96 std::cout <<
"Test completed successfully!" << std::endl;
101 LOG_ERROR(
"Unable to retrieve the video source.");
Abstract interface for tracker and video devices.
static vtkPlusBuffer * New()
PlusStatus GetOutputChannelByName(vtkPlusChannel *&aChannel, const char *aChannelId)
virtual PlusStatus DeepCopyBufferTo(vtkPlusBuffer &bufferToFill)
int main(int argc, char **argv)
static vtkIGSIOLogger * Instance()
Contains an optional timestamped circular buffer containing the video images and a number of timestam...
PlusStatus GetVideoSource(vtkPlusDataSource *&aVideoSource) const
virtual PlusStatus WriteToSequenceFile(const char *filename, bool useCompression=false)
static PlusStatus ReadDeviceSetConfigurationFromFile(vtkXMLDataElement *config, const char *filename)
Interface to a 3D positioning tool, video source, or generalized data stream.