7 #include "PlusConfigure.h" 8 #include "vtkCallbackCommand.h" 9 #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" 18 class vtkMyCallback :
public vtkCommand
21 static vtkMyCallback *New() {
return new vtkMyCallback;}
22 virtual void Execute(vtkObject *caller,
unsigned long,
void*)
27 iren->CreateTimer(VTKI_TIMER_UPDATE);
30 vtkRenderWindowInteractor *
iren;
33 int main(
int argc,
char **argv)
35 bool printHelp(
false);
36 bool renderingOff(
false);
37 bool listDevices=
false;
39 std::string videoNorm(
"NTSC_M");
40 std::string videoFormat(
"Y800 (640x480)");
41 std::string inputChannel(
"01 Video: SVideo");
43 vtksys::CommandLineArguments args;
44 args.Initialize(argc, argv);
46 int verboseLevel = vtkPlusLogger::LOG_LEVEL_UNDEFINED;
48 args.AddArgument(
"--help", vtksys::CommandLineArguments::NO_ARGUMENT, &printHelp,
"Print this help.");
49 args.AddArgument(
"--list-devices", vtksys::CommandLineArguments::NO_ARGUMENT, &listDevices,
"Show the list of available devices, norms, formats, and frame sizes and exit");
50 args.AddArgument(
"--rendering-off", vtksys::CommandLineArguments::NO_ARGUMENT, &renderingOff,
"Run test without rendering.");
51 args.AddArgument(
"--device-name", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &
deviceName,
"IC Capturing device name (Default: DFG/USB2-lt)." );
52 args.AddArgument(
"--video-norm", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &videoNorm,
"IC Capturing device video norm (Default: NTSC_M)." );
53 args.AddArgument(
"--video-format", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &videoFormat,
"IC Capturing device video format (Default: Y800 (640x480))." );
54 args.AddArgument(
"--input-channel", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputChannel,
"IC Capturing device input channel (Default: 01 Video: SVideo)." );
55 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level (1=error only, 2=warning, 3=info, 4=debug, 5=trace)");
59 std::cerr <<
"Problem parsing arguments" << std::endl;
60 std::cout <<
"\n\nvtkPlusICCapturingSourceTest1 help:" << args.GetHelp() << std::endl;
68 std::cout <<
"\n\nvtkPlusICCapturingSourceTest1 help:" << args.GetHelp() << std::endl;
72 vtkSmartPointer<vtkPlusICCapturingSource> frameGrabber = vtkSmartPointer<vtkPlusICCapturingSource>::New();
76 frameGrabber->LogListOfCaptureDevices();
80 frameGrabber->SetDeviceName(
deviceName.c_str());
81 frameGrabber->SetVideoNorm(videoNorm.c_str());
82 frameGrabber->SetVideoFormat(videoFormat.c_str());
83 frameGrabber->SetInputChannel(inputChannel.c_str());
85 frameGrabber->CreateDefaultOutputChannel();
87 LOG_INFO(
"Initialize...");
88 frameGrabber->Connect();
90 if ( frameGrabber->GetConnected() )
92 LOG_INFO(
"Start recording...");
93 frameGrabber->StartRecording();
97 frameGrabber->Disconnect();
98 LOG_ERROR(
"Unable to connect to IC capture device: " <<
deviceName );
104 LOG_INFO(
"No need for rendering, stop the device...");
105 frameGrabber->StopRecording();
106 frameGrabber->Disconnect();
107 LOG_INFO(
"Exit successfully");
111 vtkSmartPointer<vtkImageViewer2>
viewer = vtkSmartPointer<vtkImageViewer2>::New();
112 viewer->SetColorWindow(255);
113 viewer->SetColorLevel(100.5);
116 viewer->SetInputConnection(frameGrabber->GetOutputPort());
119 vtkSmartPointer<vtkRenderWindowInteractor>
iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
120 iren->SetRenderWindow(
viewer->GetRenderWindow());
126 vtkSmartPointer<vtkMyCallback> call = vtkSmartPointer<vtkMyCallback>::New();
129 iren->AddObserver(vtkCommand::TimerEvent, call);
130 iren->CreateTimer(VTKI_TIMER_FIRST);
137 frameGrabber->StopRecording();
138 frameGrabber->Disconnect();
140 LOG_INFO(
"Exit successfully");
vtkRenderWindowInteractor * iren
int main(int argc, char **argv)
static vtkIGSIOLogger * Instance()