1 #include "PlusConfigure.h" 2 #include "igsioTrackedFrame.h" 3 #include "vtkSmartPointer.h" 4 #include "vtksys/CommandLineArguments.hxx" 5 #include "vtkIGSIOTrackedFrameList.h" 11 int main(
int argc,
char **argv)
13 bool printHelp =
false;
14 vtksys::CommandLineArguments args;
16 std::string inputFileName;
17 std::string outputFileName;
18 std::string configFileName;
19 int verboseLevel=vtkPlusLogger::LOG_LEVEL_UNDEFINED;
21 args.Initialize(argc, argv);
22 args.AddArgument(
"--help", vtksys::CommandLineArguments::NO_ARGUMENT, &printHelp,
"Print this help");
23 args.AddArgument(
"--input-seq-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputFileName,
"The filename for the input ultrasound sequence to process.");
24 args.AddArgument(
"--config-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &configFileName,
"The filename for input config file.");
25 args.AddArgument(
"--output-seq-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &outputFileName,
"The filename to write the processed sequence to.");
26 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level (1=error only, 2=warning, 3=info, 4=debug, 5=trace)");
30 std::cerr <<
"Error parsing arguments" << std::endl;
31 std::cout <<
"Help: " << args.GetHelp() << std::endl;
37 std::cout << args.GetHelp() << std::endl;
43 if (inputFileName.empty())
45 std::cerr <<
"--input-seq-file not found!" << std::endl;
49 if (configFileName.empty())
51 std::cerr <<
"--config-file not found!" << std::endl;
55 if (outputFileName.empty())
57 std::cerr <<
"--output-seq-file not found!" << std::endl;
63 vtkSmartPointer<vtkXMLDataElement> configRootElement = vtkSmartPointer<vtkXMLDataElement>::New();
66 LOG_ERROR(
"Unable to read configuration from file " << configFileName.c_str());
70 vtkXMLDataElement* scanConversionElement = configRootElement->FindNestedElementWithName(
"ScanConversion");
71 if (scanConversionElement == NULL)
73 LOG_ERROR(
"Cannot find ScanConversion element in XML tree!");
77 const char* transducerGeometry = scanConversionElement->GetAttribute(
"TransducerGeometry");
78 if (transducerGeometry == NULL)
80 LOG_ERROR(
"Scan converter TransducerGeometry is undefined!");
86 vtkSmartPointer<vtkPlusUsScanConvert> scanConverter;
87 if (STRCASECMP(transducerGeometry,
"CURVILINEAR")==0)
91 else if (STRCASECMP(transducerGeometry,
"LINEAR")==0)
97 LOG_ERROR(
"Invalid scan converter TransducerGeometry: " << transducerGeometry);
100 scanConverter->ReadConfiguration(scanConversionElement);
104 vtkSmartPointer<vtkIGSIOTrackedFrameList> inputFrameList = vtkSmartPointer<vtkIGSIOTrackedFrameList>::New();
106 int numberOfFrames = inputFrameList->GetNumberOfTrackedFrames();
110 vtkSmartPointer<vtkIGSIOTrackedFrameList> outputFrameList = vtkSmartPointer<vtkIGSIOTrackedFrameList>::New();
114 for (
int frameIndex = 0; frameIndex < numberOfFrames; frameIndex ++ )
116 igsioTrackedFrame* inputFrame = inputFrameList->GetTrackedFrame(frameIndex);
118 scanConverter->SetInputData( inputFrame->GetImageData()->GetImage() );
119 scanConverter->Update();
123 outputFrameList->AddTrackedFrame(inputFrame);
124 igsioTrackedFrame* outputFrame = outputFrameList->GetTrackedFrame(outputFrameList->GetNumberOfTrackedFrames()-1);
125 outputFrame->GetImageData()->DeepCopyFrom(scanConverter->GetOutput());
128 std::cout <<
"Writing output to file. Setting log level to error only, regardless of user specified verbose level." << std::endl;
int main(int argc, char **argv)
static vtkPlusUsScanConvertLinear * New()
static igsioStatus Write(const std::string &filename, igsioTrackedFrame *frame, US_IMAGE_ORIENTATION orientationInFile=US_IMG_ORIENT_MF, bool useCompression=true, bool EnableImageDataWrite=true)
static vtkPlusUsScanConvertCurvilinear * New()
static igsioStatus Read(const std::string &filename, vtkIGSIOTrackedFrameList *frameList)
static vtkIGSIOLogger * Instance()
static PlusStatus ReadDeviceSetConfigurationFromFile(vtkXMLDataElement *config, const char *filename)