8 #include "PlusConfigure.h" 13 #include <vtkCallbackCommand.h> 14 #include <vtkSmartPointer.h> 15 #include <vtksys/CommandLineArguments.hxx> 17 void PrintLogsCallback( vtkObject* obj,
unsigned long eid,
void* clientdata,
void* calldata );
19 int main(
int argc,
char** argv )
21 bool printHelp(
false );
22 std::string inputConfigFileName;
23 bool renderingOff(
false );
25 vtksys::CommandLineArguments args;
26 args.Initialize( argc, argv );
28 int verboseLevel = vtkPlusLogger::LOG_LEVEL_UNDEFINED;
30 args.AddArgument(
"--help", vtksys::CommandLineArguments::NO_ARGUMENT, &printHelp,
"Print this help." );
31 args.AddArgument(
"--config-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputConfigFileName,
"Config file containing the device configuration.");
32 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level (1=error only, 2=warning, 3=info, 4=debug, 5=trace)" );
36 std::cerr <<
"Problem parsing arguments" << std::endl;
37 std::cout <<
"\n\nvtkPlusOvrvisionProVideoSourceTest help:" << args.GetHelp() << std::endl;
45 std::cout <<
"\n\nvtkPlusOvrvisionProVideoSourceTest help:" << args.GetHelp() << std::endl;
50 LOG_DEBUG(
"Reading config file...");
51 vtkSmartPointer<vtkXMLDataElement> configRootElement = vtkSmartPointer<vtkXMLDataElement>::New();
54 LOG_ERROR(
"Unable to read configuration from file " << inputConfigFileName.c_str());
58 vtkSmartPointer<vtkPlusOvrvisionProVideoSource> device = vtkSmartPointer<vtkPlusOvrvisionProVideoSource>::New();
59 device->SetDeviceId(
"OvrvisionPro");
62 vtkSmartPointer<vtkCallbackCommand> callbackCommand = vtkSmartPointer<vtkCallbackCommand>::New();
64 device->AddObserver(
"WarningEvent", callbackCommand );
65 device->AddObserver(
"ErrorEvent", callbackCommand );
67 device->ReadConfiguration(configRootElement);
69 LOG_INFO(
"Initialize..." );
74 auto channel = *device->GetOutputChannelsStart();
77 LOG_ERROR(
"No channel configured for device.");
81 igsioTrackedFrame frame;
84 LOG_ERROR(
"Unable to retrieve frame from device.");
91 LOG_INFO(
"Exit successfully" );
96 void PrintLogsCallback( vtkObject* obj,
unsigned long eid,
void* clientdata,
void* calldata )
98 if ( eid == vtkCommand::GetEventIdFromString(
"WarningEvent" ) )
100 LOG_WARNING( (
const char* )calldata );
102 else if ( eid == vtkCommand::GetEventIdFromString(
"ErrorEvent" ) )
104 LOG_ERROR( (
const char* )calldata );
int main(int argc, char **argv)
void PrintLogsCallback(vtkObject *obj, unsigned long eid, void *clientdata, void *calldata)
static vtkIGSIOLogger * Instance()
static PlusStatus ReadDeviceSetConfigurationFromFile(vtkXMLDataElement *config, const char *filename)