7 #include "PlusConfigure.h" 9 #include "vtkCallbackCommand.h" 10 #include "vtkCommand.h" 11 #include "vtkImageData.h" 12 #include "vtkImageViewer2.h" 13 #include "vtkRenderWindowInteractor.h" 14 #include "vtkRenderer.h" 15 #include "vtkSmartPointer.h" 16 #include "vtksys/CommandLineArguments.hxx" 19 void PrintLogsCallback(vtkObject* obj,
unsigned long eid,
void* clientdata,
void* calldata);
21 class vtkMyCallback :
public vtkCommand
24 static vtkMyCallback *New()
25 {
return new vtkMyCallback;}
26 virtual void Execute(vtkObject *caller,
unsigned long,
void*)
30 iren->CreateTimer(VTKI_TIMER_UPDATE);
33 vtkRenderWindowInteractor *
iren;
42 int main(
int argc,
char **argv)
44 std::string iniFile=
"BkSettings/IniFile.ini";
45 bool showBmode(
false);
46 bool showSapera(
false);
47 bool printHelp(
false);
48 bool renderingOff(
false);
50 vtksys::CommandLineArguments args;
51 args.Initialize(argc, argv);
54 int verboseLevel = vtkPlusLogger::LOG_LEVEL_UNDEFINED;
56 args.AddArgument(
"--ini-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &iniFile,
"Path to the BK ini file, relative to the configuration file directory. Default: BkSettings/IniFile.ini");
57 args.AddArgument(
"--show-bmode", vtksys::CommandLineArguments::NO_ARGUMENT, &showBmode,
"Show B-mode image debug window");
58 args.AddArgument(
"--show-sapera", vtksys::CommandLineArguments::NO_ARGUMENT, &showSapera,
"Show Sapera framegrabber debug window");
59 args.AddArgument(
"--help", vtksys::CommandLineArguments::NO_ARGUMENT, &printHelp,
"Print this help.");
60 args.AddArgument(
"--rendering-off", vtksys::CommandLineArguments::NO_ARGUMENT, &renderingOff,
"Run test without rendering the video source output to the screen.");
61 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level (1=error only, 2=warning, 3=info, 4=debug, 5=trace)");
65 std::cerr <<
"Problem parsing arguments" << std::endl;
66 std::cout <<
"\n\nvtkPlusBkProFocusCameraLinkVideoSourceTest help:" << args.GetHelp() << std::endl;
74 std::cout <<
"\n\nvtkPlusBkProFocusCameraLinkVideoSourceTest help:" << args.GetHelp() << std::endl;
79 vtkSmartPointer<vtkPlusBkProFocusCameraLinkVideoSource> frameGrabber = vtkSmartPointer<vtkPlusBkProFocusCameraLinkVideoSource>::New();
81 frameGrabber->SetIniFileName(iniFile.c_str());
83 frameGrabber->SetShowBModeWindow(showBmode);
84 frameGrabber->SetShowSaperaWindow(showSapera);
87 frameGrabber->CreateDefaultOutputChannel();
89 if (frameGrabber->GetFirstActiveOutputVideoSource(videoSource) !=
PLUS_SUCCESS )
91 LOG_ERROR(
"Unable to retrieve the video source.");
96 LOG_INFO(
"Initialize...");
97 frameGrabber->Connect();
99 if ( frameGrabber->GetConnected() )
101 LOG_INFO(
"Start recording...");
102 frameGrabber->StartRecording();
106 frameGrabber->Disconnect();
107 LOG_ERROR(
"Unable to connect to framegrabber");
113 LOG_INFO(
"No need for rendering, stop the device...");
114 frameGrabber->StopRecording();
115 frameGrabber->Disconnect();
116 LOG_INFO(
"Exit successfully");
120 vtkSmartPointer<vtkImageViewer2>
viewer = vtkSmartPointer<vtkImageViewer2>::New();
122 viewer->SetColorWindow(255);
123 viewer->SetColorLevel(100.5);
124 viewer->SetSize(1024,768);
126 viewer->SetInput(frameGrabber->GetOutput());
129 vtkSmartPointer<vtkRenderWindowInteractor>
iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
130 iren->SetRenderWindow(
viewer->GetRenderWindow());
136 vtkSmartPointer<vtkMyCallback> call = vtkSmartPointer<vtkMyCallback>::New();
139 iren->AddObserver(vtkCommand::TimerEvent, call);
140 iren->CreateTimer(VTKI_TIMER_FIRST);
146 frameGrabber->StopRecording();
147 frameGrabber->Disconnect();
149 LOG_INFO(
"Exit successfully");
vtkRenderWindowInteractor * iren
virtual PlusStatus SetInputImageOrientation(US_IMAGE_ORIENTATION imageOrientation)
static vtkPlusConfig * GetInstance()
void PrintLogsCallback(vtkObject *obj, unsigned long eid, void *clientdata, void *calldata)
int main(int argc, char **argv)
static vtkIGSIOLogger * Instance()
Interface to a 3D positioning tool, video source, or generalized data stream.