7 #include "PlusConfigure.h" 8 #include "vtksys/CommandLineArguments.hxx" 10 #include "vtkImageData.h" 11 #include "vtkImageViewer2.h" 12 #include "vtkRenderWindowInteractor.h" 13 #include "vtkRenderer.h" 14 #include "vtkSmartPointer.h" 15 #include "vtkCommand.h" 16 #include "vtkCallbackCommand.h" 18 void PrintLogsCallback(vtkObject* obj,
unsigned long eid,
void* clientdata,
void* calldata);
20 class vtkMyCallback :
public vtkCommand
23 static vtkMyCallback *New()
24 {
return new vtkMyCallback;}
25 virtual void Execute(vtkObject *caller,
unsigned long,
void*)
27 frameGrabber->GetImage(leftImage,NULL);
28 viewer->SetInputData(leftImage);
32 iren->CreateTimer(VTKI_TIMER_UPDATE);
35 vtkRenderWindowInteractor *
iren;
37 vtkImageData *leftImage;
46 int main(
int argc,
char **argv)
48 std::string serialNumber;
50 bool printHelp(
false);
51 bool renderingOff(
false);
53 vtksys::CommandLineArguments args;
54 args.Initialize(argc, argv);
56 int verboseLevel = vtkPlusLogger::LOG_LEVEL_UNDEFINED;
58 args.AddArgument(
"--serial-number", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &serialNumber,
"Serial number of the Epiphan device to connect");
59 args.AddArgument(
"--frame-rate", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &frameRate,
"Requested acquisition frame rate (in FPS, default = 30)");
60 args.AddArgument(
"--help", vtksys::CommandLineArguments::NO_ARGUMENT, &printHelp,
"Print this help.");
61 args.AddArgument(
"--rendering-off", vtksys::CommandLineArguments::NO_ARGUMENT, &renderingOff,
"Run test without rendering.");
62 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level (1=error only, 2=warning, 3=info, 4=debug, 5=trace)");
66 std::cerr <<
"Problem parsing arguments" << std::endl;
67 std::cout <<
"\n\nvtkPlusEpiphanVideoSourceTest help:" << args.GetHelp() << std::endl;
75 std::cout <<
"\n\nvtkPlusEpiphanVideoSourceTest help:" << args.GetHelp() << std::endl;
80 vtkSmartPointer<vtkPlusMicronTracker> frameGrabber = vtkSmartPointer<vtkPlusMicronTracker>::New();
82 frameGrabber->SetAcquisitionRate(frameRate);
85 vtkSmartPointer<vtkCallbackCommand> callbackCommand = vtkSmartPointer<vtkCallbackCommand>::New();
87 frameGrabber->AddObserver(
"WarningEvent", callbackCommand);
88 frameGrabber->AddObserver(
"ErrorEvent", callbackCommand);
90 LOG_INFO(
"Initialize...");
94 LOG_ERROR(
"Unable to connect to device");
98 LOG_INFO(
"Start recording...");
101 LOG_ERROR(
"Unable to connect to device");
107 LOG_INFO(
"No need for rendering, stop the device...");
108 frameGrabber->StopRecording();
109 frameGrabber->Disconnect();
110 LOG_INFO(
"Exit successfully");
114 vtkSmartPointer<vtkImageViewer2>
viewer = vtkSmartPointer<vtkImageViewer2>::New();
116 viewer->SetColorWindow(255);
117 viewer->SetColorLevel(100.5);
118 viewer->SetSize(1024,768);
120 vtkSmartPointer<vtkImageData> leftImage=vtkSmartPointer<vtkImageData>::New();
121 frameGrabber->GetImage(leftImage,NULL);
122 viewer->SetInputData(leftImage);
125 vtkSmartPointer<vtkRenderWindowInteractor>
iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
126 iren->SetRenderWindow(
viewer->GetRenderWindow());
132 vtkSmartPointer<vtkMyCallback> call = vtkSmartPointer<vtkMyCallback>::New();
135 call->frameGrabber=frameGrabber;
136 call->leftImage=leftImage;
137 iren->AddObserver(vtkCommand::TimerEvent, call);
138 iren->CreateTimer(VTKI_TIMER_FIRST);
144 LOG_INFO(
"Exit successfully");
152 if ( eid == vtkCommand::GetEventIdFromString(
"WarningEvent") )
154 LOG_WARNING((
const char*)calldata);
156 else if ( eid == vtkCommand::GetEventIdFromString(
"ErrorEvent") )
158 LOG_ERROR((
const char*)calldata);
void PrintLogsCallback(vtkObject *obj, unsigned long eid, void *clientdata, void *calldata)
vtkRenderWindowInteractor * iren
Interface class to Claron MicronTracker optical trackers.
int main(int argc, char **argv)
static vtkIGSIOLogger * Instance()