14 #include "PlusConfigure.h" 15 #include "vtkImageData.h" 16 #include "vtkSmartPointer.h" 18 #include "vtkXMLUtilities.h" 19 #include "vtksys/CommandLineArguments.hxx" 20 #include "vtkImageViewer.h" 21 #include "vtkActor2D.h" 22 #include "vtkRenderWindowInteractor.h" 25 class vtkMyCallback :
public vtkCommand
28 static vtkMyCallback* New() {
return new vtkMyCallback; }
30 virtual void Execute(vtkObject* caller,
unsigned long,
void*)
35 m_Interactor->CreateTimer(VTKI_TIMER_UPDATE);
38 vtkRenderWindowInteractor* m_Interactor;
39 vtkImageViewer* m_Viewer;
45 m_Interactor =
nullptr;
50 int main(
int argc,
char* argv[])
52 bool printHelp(
false);
53 bool renderingOff(
false);
54 std::string inputConfigFileName;
55 std::string outputFileName(
"WinProbeOutputSeq.nrrd");
56 int verboseLevel = vtkPlusLogger::LOG_LEVEL_DEBUG;
58 vtksys::CommandLineArguments args;
59 args.Initialize(argc, argv);
60 args.AddArgument(
"--help", vtksys::CommandLineArguments::NO_ARGUMENT, &printHelp,
"Print this help.");
61 args.AddArgument(
"--config-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputConfigFileName,
"Config file containing the device configuration.");
62 args.AddArgument(
"--rendering-off", vtksys::CommandLineArguments::NO_ARGUMENT, &renderingOff,
"Run test without rendering.");
63 args.AddArgument(
"--output-seq-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &outputFileName,
"Filename of the output video buffer sequence metafile (Default: VideoBufferMetafile)");
64 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level 1=error only, 2=warning, 3=info, 4=debug, 5=trace)");
68 std::cerr <<
"Problem parsing arguments" << std::endl;
69 std::cout <<
"\nvtkPlusWinProbeVideoSourceTest help:" << args.GetHelp() << std::endl;
76 std::cout <<
"\n\nvtkPlusWinProbeVideoSourceTest help:" << args.GetHelp() << std::endl;
81 vtkSmartPointer< vtkPlusWinProbeVideoSource > WinProbeDevice = vtkSmartPointer< vtkPlusWinProbeVideoSource >::New();
82 WinProbeDevice->SetDeviceId(
"VideoDeviceWP");
84 vtkSmartPointer<vtkXMLDataElement> configRootElement = vtkSmartPointer<vtkXMLDataElement>::New();
85 if(STRCASECMP(inputConfigFileName.c_str(),
"") != 0)
87 LOG_DEBUG(
"Reading config file...");
91 LOG_ERROR(
"Unable to read configuration from file " << inputConfigFileName.c_str());
95 WinProbeDevice->ReadConfiguration(configRootElement);
98 std::cout <<
"\n" << *WinProbeDevice;
102 LOG_ERROR(
"Unable to connect to WinProbe Probe");
107 WinProbeDevice->StartRecording();
108 std::cout <<
"\n" << *WinProbeDevice;
109 WinProbeDevice->StopRecording();
112 double tgc = WinProbeDevice->GetTimeGainCompensation(7);
113 tgc = WinProbeDevice->GetTimeGainCompensation(3);
114 WinProbeDevice->SetTimeGainCompensation(3, 0.2);
115 tgc = WinProbeDevice->GetTimeGainCompensation(3);
118 uint16_t uVal = WinProbeDevice->GetLogLinearKnee();
119 WinProbeDevice->SetLogLinearKnee(123);
120 uVal = WinProbeDevice->GetLogLinearKnee();
122 WinProbeDevice->StartRecording();
127 WinProbeDevice->ARFIPush();
131 if(WinProbeDevice->GetOutputChannelByName(bChannel,
"VideoStream") !=
PLUS_SUCCESS)
133 LOG_ERROR(
"Unable to locate the channel with Id=\"VideoStream\". Check config file.");
138 if(WinProbeDevice->GetOutputChannelByName(rfChannel,
"AdditionalStream") !=
PLUS_SUCCESS)
140 LOG_WARNING(
"Unable to locate the channel with Id=\"AdditionalStream\". Additional mode will not be used.");
143 WinProbeDevice->FreezeDevice(
true);
157 WinProbeDevice->WriteConfiguration(configRootElement);
158 bool success = vtkXMLUtilities::WriteElementToFile(configRootElement, (outputFileName +
".xml").c_str());
161 LOG_ERROR(
"Unable to write configuration to: " << outputFileName +
".xml");
165 LOG_INFO(
"Configuration file written to: " << outputFileName +
".xml");
168 WinProbeDevice->FreezeDevice(
false);
172 vtkSmartPointer<vtkImageViewer>
viewer = vtkSmartPointer<vtkImageViewer>::New();
173 viewer->SetInputConnection(WinProbeDevice->GetOutputPort(0));
174 viewer->SetColorWindow(255);
175 viewer->SetColorLevel(127.5);
177 viewer->SetSize(256, 640);
180 vtkSmartPointer<vtkRenderWindowInteractor>
iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
181 iren->SetRenderWindow(
viewer->GetRenderWindow());
187 vtkSmartPointer<vtkMyCallback> call = vtkSmartPointer<vtkMyCallback>::New();
188 call->m_Interactor =
iren;
190 iren->AddObserver(vtkCommand::TimerEvent, call);
191 iren->CreateTimer(VTKI_TIMER_FIRST);
198 WinProbeDevice->StopRecording();
199 WinProbeDevice->Disconnect();
virtual PlusStatus WriteToSequenceFile(const char *filename, bool useCompression=false)
vtkRenderWindowInteractor * iren
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
static PlusStatus ReadDeviceSetConfigurationFromFile(vtkXMLDataElement *config, const char *filename)
Interface to a 3D positioning tool, video source, or generalized data stream.