int main() { // Import images from files using the ImageFileStreamer ImageFileStreamer::pointer streamer = ImageFileStreamer::New(); // The hashtag here will be replaced with an integer, starting with 0 as default streamer->setFilenameFormat(std::string(FAST_TEST_DATA_DIR)+"/US-2Dt/US-2Dt_#.mhd"); // Renderer image ImageRenderer::pointer renderer = ImageRenderer::New(); renderer->addInputConnection(streamer->getOutputPort()); SimpleWindow::pointer window = SimpleWindow::New(); window->addRenderer(renderer); window->set2DMode(); #ifdef FAST_CONTINUOUS_INTEGRATION // This will automatically close the window after 5 seconds, used for CI testing window->setTimeout(5*1000); #endif window->start(); }
int main() { Reporter::setGlobalReportMethod(Reporter::COUT); ImageFileStreamer::pointer streamer = ImageFileStreamer::New(); streamer->setFilenameFormat(Config::getTestDataPath() + "US/JugularVein/US-2D_#.mhd"); streamer->setTimestampFilename(Config::getTestDataPath() + "US/JugularVein/timestamps.fts"); streamer->enableLooping(); PixelClassifier::pointer segmentation = PixelClassifier::New(); segmentation->setNrOfClasses(3); segmentation->setScaleFactor(1.0f / 255.0f); const auto engine = segmentation->getInferenceEngine()->getName(); if(engine == "TensorFlow") { // TensorFlow needs to know what the output node is called segmentation->addOutputNode(0, "conv2d_23/truediv"); } else if(engine == "TensorRT") { // TensorRT needs to know everything about the input and output nodes segmentation->addInputNode(0, "input_image", NodeType::IMAGE, TensorShape({-1, 1, 256, 256})); segmentation->addOutputNode(0, "permute_2/transpose"); } segmentation->load(join(Config::getTestDataPath(), "NeuralNetworkModels/jugular_vein_segmentation." + segmentation->getInferenceEngine()->getDefaultFileExtension())); segmentation->setInputConnection(streamer->getOutputPort()); segmentation->enableRuntimeMeasurements(); SegmentationRenderer::pointer segmentationRenderer = SegmentationRenderer::New(); segmentationRenderer->addInputConnection(segmentation->getOutputPort()); segmentationRenderer->setOpacity(0.25); segmentationRenderer->setColor(Segmentation::LABEL_FOREGROUND, Color::Red()); segmentationRenderer->setColor(Segmentation::LABEL_BLOOD, Color::Blue()); ImageRenderer::pointer imageRenderer = ImageRenderer::New(); imageRenderer->setInputConnection(streamer->getOutputPort()); SimpleWindow::pointer window = SimpleWindow::New(); window->addRenderer(imageRenderer); window->addRenderer(segmentationRenderer); window->set2DMode(); window->getView()->setBackgroundColor(Color::Black()); window->start(); segmentation->getAllRuntimes()->printAll(); }
#include "FAST/Tests/catch.hpp" #include "FAST/DeviceManager.hpp" #include <boost/thread.hpp> #include "FAST/Streamers/ImageFileStreamer.hpp" #include "FAST/Tests/DummyObjects.hpp" #include "FAST/Data/Image.hpp" using namespace fast; TEST_CASE("No filename format given to ImageFileStreamer", "[fast][ImageFileStreamer]") { ImageFileStreamer::pointer mhdStreamer = ImageFileStreamer::New(); CHECK_THROWS(mhdStreamer->update()); } TEST_CASE("No hash tag in filename format given to ImageFileStreamer", "[fast][ImageFileStreamer]") { ImageFileStreamer::pointer mhdStreamer = ImageFileStreamer::New(); CHECK_THROWS(mhdStreamer->setFilenameFormat("asd")); } TEST_CASE("Default streaming mode is NEWEST_FRAME_ONLY", "[fast][ImageFileStreamer]") { ImageFileStreamer::pointer mhdStreamer = ImageFileStreamer::New(); CHECK(mhdStreamer->getStreamingMode() == STREAMING_MODE_NEWEST_FRAME_ONLY); } /* // TODO fix this, will not work because it is another thread that throws the exception TEST_CASE("Wrong filename format given to ImageFileStreamer", "[fast][ImageFileStreamer]") { ImageFileStreamer::pointer mhdStreamer = ImageFileStreamer::New(); mhdStreamer->setFilenameFormat("asd#asd"); DynamicData::pointer image = mhdStreamer->getOutput(); std::cout << "asd" << std::endl;
TriangleRenderer->setInputConnection(segmentation->getOutputPort()); ImageRenderer::pointer imageRenderer = ImageRenderer::New(); imageRenderer->setInputConnection(streamer->getOutputPort()); SimpleWindow::pointer window = SimpleWindow::New(); window->addRenderer(imageRenderer); window->addRenderer(TriangleRenderer); window->set2DMode(); window->start(); } */ TEST_CASE("Model based segmentation with spline model on 2D cardiac US data", "[fast][ModelBasedSegmentation][2d][cardiac][visual]") { ImageFileStreamer::pointer streamer = ImageFileStreamer::New(); //streamer->setFilenameFormat(Config::getTestDataPath()+"US/Heart/ApicalTwoChamber/US-2D_#.mhd"); //streamer->setFilenameFormat(Config::getTestDataPath()+"US/Heart/ApicalLongAxis/US-2D_#.mhd"); streamer->setFilenameFormat(Config::getTestDataPath()+"US/Heart/ApicalFourChamber/US-2D_#.mhd"); //streamer->setFilenameFormat("/home/smistad/data/ultrasound_smistad_heart/1234/H1ADBNGK/US-2D_#.mhd"); //streamer->setFilenameFormat("/home/smistad/data/ultrasound_smistad_heart/1234/H1ADCKOO/US-2D_#.mhd"); //streamer->setFilenameFormat("/home/smistad/data/ultrasound_smistad_heart/1234/H1ADCL8Q/US-2D_#.mhd"); streamer->enableLooping(); //streamer->setStreamingMode(STREAMING_MODE_PROCESS_ALL_FRAMES); streamer->setSleepTime(50); // Control points for spline model std::vector<Vector2f> controlPoints = { Vector2f(89,22), // Apex Vector2f(100,31),
int main(int argc, char** argv) { std::vector<std::string> recordings = { "/home/smistad/AssistantTestData/1/US-Acq_03_20150608T103739/Acquisition/US-Acq_03_20150608T103739_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/1/US-Acq_04_20150608T103837/Acquisition/US-Acq_04_20150608T103837_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/1/US-Acq_07_20150608T104148/Acquisition/US-Acq_07_20150608T104148_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/1/US-Acq_08_20150608T104238/Acquisition/US-Acq_08_20150608T104238_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/0/US-Acq_03_20150608T102144/Acquisition/US-Acq_03_20150608T102144_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/0/US-Acq_04_20150608T102242/Acquisition/US-Acq_04_20150608T102242_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/0/US-Acq_07_20150608T102703/Acquisition/US-Acq_07_20150608T102703_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/0/US-Acq_08_20150608T102854/Acquisition/US-Acq_08_20150608T102854_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/2/US-Acq_03_20150608T104805/Acquisition/US-Acq_03_20150608T104805_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/2/US-Acq_04_20150608T104910/Acquisition/US-Acq_04_20150608T104910_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/2/US-Acq_07_20150608T105549/Acquisition/US-Acq_07_20150608T105549_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/2/US-Acq_08_20150608T105649/Acquisition/US-Acq_08_20150608T105649_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/3/US-Acq_03_20150608T113646/Acquisition/US-Acq_03_20150608T113646_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/3/US-Acq_04_20150608T113750/Acquisition/US-Acq_04_20150608T113750_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/3/US-Acq_07_20150608T114115/Acquisition/US-Acq_07_20150608T114115_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/3/US-Acq_08_20150608T114217/Acquisition/US-Acq_08_20150608T114217_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/4/US-Acq_03_20150608T112610/Acquisition/US-Acq_03_20150608T112610_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/4/US-Acq_04_20150608T112656/Acquisition/US-Acq_04_20150608T112656_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/4/US-Acq_08_20150608T113129/Acquisition/US-Acq_08_20150608T113129_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/4/US-Acq_09_20150608T113245/Acquisition/US-Acq_09_20150608T113245_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/5/US-Acq_03_20150608T111610/Acquisition/US-Acq_03_20150608T111610_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/5/US-Acq_04_20150608T111701/Acquisition/US-Acq_04_20150608T111701_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/5/US-Acq_07_20150608T111940/Acquisition/US-Acq_07_20150608T111940_Image_Transducer_#.mhd", "/home/smistad/AssistantTestData/6/0/US-2D_#.mhd", "/home/smistad/AssistantTestData/6/1/US-2D_#.mhd", "/home/smistad/AssistantTestData/6/2/US-2D_#.mhd", "/home/smistad/AssistantTestData/6/3/US-2D_#.mhd", "/home/smistad/AssistantTestData/6/4/US-2D_#.mhd", "/home/smistad/AssistantTestData/7/0/US-2D_#.mhd", "/home/smistad/AssistantTestData/7/1/US-2D_#.mhd", "/home/smistad/AssistantTestData/7/2/US-2D_#.mhd", "/home/smistad/AssistantTestData/7/3/US-2D_#.mhd", "/home/smistad/AssistantTestData/8/0/US-2D_#.mhd", "/home/smistad/AssistantTestData/8/1/US-2D_#.mhd", "/home/smistad/AssistantTestData/8/2/US-2D_#.mhd", "/home/smistad/AssistantTestData/8/3/US-2D_#.mhd", "/home/smistad/AssistantTestData/9/0/US-2D_#.mhd", "/home/smistad/AssistantTestData/9/1/US-2D_#.mhd", "/home/smistad/AssistantTestData/9/2/US-2D_#.mhd", "/home/smistad/AssistantTestData/9/3/US-2D_#.mhd", "/home/smistad/AssistantTestData/10/0/US-2D_#.mhd", "/home/smistad/AssistantTestData/10/1/US-2D_#.mhd", "/home/smistad/AssistantTestData/10/2/US-2D_#.mhd", "/home/smistad/AssistantTestData/10/3/US-2D_#.mhd", "/home/smistad/AssistantTestData/11/0/US-2D_#.mhd", "/home/smistad/AssistantTestData/11/1/US-2D_#.mhd", "/home/smistad/AssistantTestData/11/2/US-2D_#.mhd", "/home/smistad/AssistantTestData/11/3/US-2D_#.mhd", "/home/smistad/AssistantTestData/12/0/US-2D_#.mhd", "/home/smistad/AssistantTestData/12/1/US-2D_#.mhd", "/home/smistad/AssistantTestData/12/2/US-2D_#.mhd", "/home/smistad/AssistantTestData/12/3/US-2D_#.mhd", "/media/smistad/New Volume/Carotis/Erik/2016-06-02-140622/US-2D_#.mhd", "/media/smistad/New Volume/Carotis/Erik/2016-06-02-140721/US-2D_#.mhd", "/media/smistad/New Volume/Carotis/Erik/2016-06-02-140846/US-2D_#.mhd", "/media/smistad/New Volume/Carotis/Erik/2016-06-02-140923/US-2D_#.mhd" }; uint recordingID = 0; if(argc != 2) { std::cout << "Usage: " << argv[0] << "<recording-id: 0-" << recordings.size() << ">" << std::endl; return 0; } else { recordingID = atoi(argv[1]); } ImageFileStreamer::pointer streamer = ImageFileStreamer::New(); streamer->setStreamingMode(STREAMING_MODE_PROCESS_ALL_FRAMES); streamer->setFilenameFormat(recordings[recordingID]); streamer->update(); UltrasoundVesselDetection::pointer detector = UltrasoundVesselDetection::New(); detector->setInputConnection(streamer->getOutputPort()); detector->enableRuntimeMeasurements(); SegmentationRenderer::pointer segmentationRenderer = SegmentationRenderer::New(); segmentationRenderer->addInputConnection(detector->getOutputSegmentationPort()); segmentationRenderer->setFillArea(false); ImageRenderer::pointer imageRenderer = ImageRenderer::New(); imageRenderer->addInputConnection(streamer->getOutputPort()); SimpleWindow::pointer window = SimpleWindow::New(); window->addRenderer(imageRenderer); window->addRenderer(segmentationRenderer); window->set2DMode(); window->setWidth(1920); window->setHeight(1080); window->start(); detector->getRuntime("ellipse fitting")->print(); detector->getRuntime("candidate selection")->print(); detector->getRuntime("classifier")->print(); detector->getRuntime("segmentation")->print(); }