コード例 #1
0
ファイル: smitta.c プロジェクト: h4xxel/smitta
void simulation_run(Simulation *sim, void (*visualize)(Simulation *)) {
	/*
		Continously run the simulation until no more infected cells exist
	*/
	
	if(!sim->quiet)
		visualize(sim);
	
	while(sim->statistic.total.infected) {
		if(sim->interactive) {
			if(getchar() == 'q')
				return;
		} else {
			if(sim->delay)
				usleep(sim->delay);
		}
		
		sim->statistic.last_step.infected = 0;
		sim->statistic.last_step.dead = 0;
		sim->statistic.last_step.cured = 0;
		
		simulation_step(sim);
		
		sim->statistic.total.infected += sim->statistic.last_step.infected - sim->statistic.last_step.cured - sim->statistic.last_step.dead;
		sim->statistic.total.dead += sim->statistic.last_step.dead;
		sim->statistic.total.immune += sim->statistic.last_step.cured;
		
		if(!sim->quiet)
			visualize(sim);
	}
}
コード例 #2
0
ファイル: GroundKernel.cpp プロジェクト: EricAlex/PDAL
int GroundKernel::execute()
{
    PointTable table;

    Stage& readerStage(makeReader(m_inputFile, ""));

    Options groundOptions;
    groundOptions.add("max_window_size", m_maxWindowSize);
    groundOptions.add("slope", m_slope);
    groundOptions.add("max_distance", m_maxDistance);
    groundOptions.add("initial_distance", m_initialDistance);
    groundOptions.add("cell_size", m_cellSize);
    groundOptions.add("classify", m_classify);
    groundOptions.add("extract", m_extract);
    groundOptions.add("approximate", m_approximate);

    Stage& groundStage = makeFilter("filters.ground", readerStage);
    groundStage.addOptions(groundOptions);

    // setup the Writer and write the results
    Stage& writer(makeWriter(m_outputFile, groundStage, ""));

    writer.prepare(table);

    // process the data, grabbing the PointViewSet for visualization of the
    // resulting PointView
    PointViewSet viewSetOut = writer.execute(table);

    if (isVisualize())
        visualize(*viewSetOut.begin());
    //visualize(*viewSetIn.begin(), *viewSetOut.begin());

    return 0;
}
コード例 #3
0
ファイル: player.cpp プロジェクト: biemme14/gdemu
void setup()
{
  int i;

  GD.begin();

  GD.wr16(RAM_SPRPAL + 2 * 255, TRANSPARENT);

  // draw 32 circles into 32 sprite images
  for (i = 0; i < 32; i++) {
    GD.wr16(RAM_SPRPAL + 2 * i, RGB(8 * i, 64, 255 - 8 * i));
    int dst = RAM_SPRIMG + 256 * i;
    GD.__wstart(dst);
    byte x, y;
    int r2 = min(i * i, 256);
    for (y = 0; y < 16; y++) {
      for (x = 0; x < 16; x++) {
        byte pixel;
        if ((x * x + y * y) <= r2)
          pixel = i;    // use color above
        else
          pixel = 0xff; // transparent
        SPI.transfer(pixel);
      }
    }
    GD.__end();
  }
  for (i = 0; i < 64; i++)
    visualize(i, 0);
}
コード例 #4
0
ファイル: parse.c プロジェクト: yangyao2/fsop
int main ()
{
	//FILE* fptr;
	char filename[20];
	while(1)
	{
		printf("please input the file name you wish to parse\n ");
		scanf("%s",filename);
		fptr=fopen(filename,"r");
		if (fptr)
			break;
		printf("invalid file name\n");

	}

	enable_library=-1;
	while (1)
	{
		printf("Do you wish to include library files? Enter 1 for yes and 0 for no\n");
		scanf("%d",&enable_library);
		if (enable_library==0||enable_library==1)
			break;
		printf("Invalid input\n");
	}
	parse_files(filename);
	printtoterminal();
	analyzeresult();
	visualize();
}
コード例 #5
0
ファイル: main.c プロジェクト: luxiaotong/leetcode
int main() {
    int tree_arr[] = {4, 2, 7, 1, 3, 6, 9};
    int len = sizeof(tree_arr)/sizeof(int);
    struct TreeNode *root = deserializer(tree_arr, len);
    visualize(root, len);

    root = invertTree(root);
    visualize(root, len);


    int tree_arr2[] = {};
    int len2 = sizeof(tree_arr2)/sizeof(int);
    struct TreeNode *root2 = deserializer(tree_arr2, len2);
    visualize(root2, len);


    return 0;
}
コード例 #6
0
ファイル: GroundKernel.cpp プロジェクト: boundlessgeo/PDAL
int GroundKernel::execute()
{
    PointTable table;

    Options readerOptions;
    readerOptions.add<std::string>("filename", m_inputFile);
    setCommonOptions(readerOptions);

    Stage& readerStage(Kernel::makeReader(m_inputFile));
    readerStage.setOptions(readerOptions);

    Options groundOptions;
    groundOptions.add<double>("maxWindowSize", m_maxWindowSize);
    groundOptions.add<double>("slope", m_slope);
    groundOptions.add<double>("maxDistance", m_maxDistance);
    groundOptions.add<double>("initialDistance", m_initialDistance);
    groundOptions.add<double>("cellSize", m_cellSize);
    groundOptions.add<bool>("classify", m_classify);
    groundOptions.add<bool>("extract", m_extract);
    groundOptions.add<bool>("approximate", m_approximate);
    groundOptions.add<bool>("debug", isDebug());
    groundOptions.add<uint32_t>("verbose", getVerboseLevel());

    StageFactory f;
    std::unique_ptr<Stage> groundStage(f.createStage("filters.ground"));
    groundStage->setOptions(groundOptions);
    groundStage->setInput(readerStage);

    // setup the Writer and write the results
    Options writerOptions;
    writerOptions.add<std::string>("filename", m_outputFile);
    setCommonOptions(writerOptions);

    Stage& writer(Kernel::makeWriter(m_outputFile, *groundStage));
    writer.setOptions(writerOptions);

    std::vector<std::string> cmd = getProgressShellCommand();
    UserCallback *callback =
        cmd.size() ? (UserCallback *)new ShellScriptCallback(cmd) :
        (UserCallback *)new HeartbeatCallback();

    writer.setUserCallback(callback);

    applyExtraStageOptionsRecursive(&writer);
    writer.prepare(table);

    // process the data, grabbing the PointViewSet for visualization of the
    // resulting PointView
    PointViewSet viewSetOut = writer.execute(table);

    if (isVisualize())
        visualize(*viewSetOut.begin());
    //visualize(*viewSetIn.begin(), *viewSetOut.begin());

    return 0;
}
コード例 #7
0
ファイル: synth_lua.c プロジェクト: bobbens/ArtTreeKS
static int synL_visualize( lua_State *L )
{
   synthesis_t *syn_a, *syn_b;
   syn_a = luaL_checksyn(L,1);
   if (lua_gettop(L) > 1)
      syn_b = luaL_checksyn(L,2);
   else
      syn_b = NULL;
   visualize( syn_a, syn_b );
   return 0;
}
コード例 #8
0
ファイル: SmoothKernel.cpp プロジェクト: EricAlex/PDAL
int SmoothKernel::execute()
{
    PointTable table;

    Stage& readerStage(makeReader(m_inputFile, ""));

    // go ahead and prepare/execute on reader stage only to grab input
    // PointViewSet, this makes the input PointView available to both the
    // processing pipeline and the visualizer
    readerStage.prepare(table);
    PointViewSet viewSetIn = readerStage.execute(table);

    // the input PointViewSet will be used to populate a BufferReader that is
    // consumed by the processing pipeline
    PointViewPtr input_view = *viewSetIn.begin();

    PipelineManager manager;
    manager.commonOptions() = m_manager.commonOptions();
    manager.stageOptions() = m_manager.stageOptions();

    BufferReader& bufferReader =
        static_cast<BufferReader&>(manager.makeReader("", "readers.buffer"));
    bufferReader.addView(input_view);

    std::ostringstream ss;
    ss << "{";
    ss << "  \"pipeline\": {";
    ss << "    \"filters\": [{";
    ss << "      \"name\": \"MovingLeastSquares\"";
    ss << "      }]";
    ss << "    }";
    ss << "}";

    Options smoothOptions;
    smoothOptions.add("json", ss.str());

    Stage& smoothStage = manager.makeFilter("filters.pclblock", bufferReader);
    smoothStage.addOptions(smoothOptions);

    Stage& writer(Kernel::makeWriter(m_outputFile, smoothStage, ""));

    writer.prepare(table);

    // process the data, grabbing the PointViewSet for visualization of the
    // resulting PointView
    PointViewSet viewSetOut = writer.execute(table);

    if (isVisualize())
        visualize(*viewSetOut.begin());
    //visualize(*viewSetIn.begin(), *viewSetOut.begin());

    return 0;
}
コード例 #9
0
void view_file( const std::string& fileName )
{
	pcl::PointCloud<pcl::PointXYZ>::Ptr pScene( new pcl::PointCloud<pcl::PointXYZ>() );

	if (pcl::io::loadPCDFile( fileName, *pScene ) < 0)
	{
		std::cout << "Error loading scene cloud." << std::endl;
		return;
	}

	visualize( pScene );
}
コード例 #10
0
ファイル: player.cpp プロジェクト: biemme14/gdemu
void adsr()  // handle ADSR for 64 voices
{
  byte v;
  for (v = 0; v < 64; v++) {
    int d = target[v] - amp[v]; // +ve means need to increase
    if (d) {
      if (d > 0)
        amp[v] += 4;  // attack
      else
        amp[v]--;     // decay
      setvol(v, amp[v]);
      visualize(v, amp[v]);
    }
  }
}
コード例 #11
0
ファイル: pack.c プロジェクト: Qix-/CS253-lab
unsigned int pack(unsigned char red,
                  unsigned char green,
                  unsigned char blue,
                  unsigned char alpha)
{
    printf("Pack red=%u, green=%u, blue=%u, alpha=%u\n",red,green,blue,alpha);
    unsigned int result = UINT_MAX;
    printf("result %u\n",result);
    visualize(result);

    /* result = result<<24;  */

    // pack it here

    return result;
}
コード例 #12
0
ファイル: darknet.c プロジェクト: domoritz/darknet
int main(int argc, char **argv)
{
    //test_resize("data/bad.jpg");
    //test_box();
    //test_convolutional_layer();
    if(argc < 2){
        fprintf(stderr, "usage: %s <function>\n", argv[0]);
        return 0;
    }
    gpu_index = find_int_arg(argc, argv, "-i", 0);
    if(find_arg(argc, argv, "-nogpu")) gpu_index = -1;

#ifndef GPU
    gpu_index = -1;
#else
    if(gpu_index >= 0){
        cudaSetDevice(gpu_index);
    }
#endif

    if(0==strcmp(argv[1], "imagenet")){
        run_imagenet(argc, argv);
    } else if (0 == strcmp(argv[1], "detection")){
        run_detection(argc, argv);
    } else if (0 == strcmp(argv[1], "writing")){
        run_writing(argc, argv);
    } else if (0 == strcmp(argv[1], "test")){
        test_resize(argv[2]);
    } else if (0 == strcmp(argv[1], "captcha")){
        run_captcha(argc, argv);
    } else if (0 == strcmp(argv[1], "nightmare")){
        run_nightmare(argc, argv);
    } else if (0 == strcmp(argv[1], "change")){
        change_rate(argv[2], atof(argv[3]), (argc > 4) ? atof(argv[4]) : 0);
    } else if (0 == strcmp(argv[1], "rgbgr")){
        rgbgr_net(argv[2], argv[3], argv[4]);
    } else if (0 == strcmp(argv[1], "partial")){
        partial(argv[2], argv[3], argv[4], atoi(argv[5]));
    } else if (0 == strcmp(argv[1], "visualize")){
        visualize(argv[2], (argc > 3) ? argv[3] : 0);
    } else if (0 == strcmp(argv[1], "imtest")){
        test_resize(argv[2]);
    } else {
        fprintf(stderr, "Not an option: %s\n", argv[1]);
    }
    return 0;
}
コード例 #13
0
static void display(void)
{
  ++g_frameCounter;

  // clear the framebuffer
  glClearColor(0.7, 0.6, 0.3, 1.0);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity ();



  // clear framebuffer from uv render pass
  glClearColor(0.7, 0.6, 0.3, 1.0);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


  // draw
  g_brush->clearBrushTexture();
  if(g_mouseDown[0])
  {
    g_brush->renderBrushToTransferTexture(g_mouseLoc.u, g_mouseLoc.v);
  }
  else if(g_mouseDown[1])
  {
    g_brush->renderBrushToTransferTexture(gloost::frand(), gloost::frand());
  }
  else if(g_mouseDown[2])
  {
    g_brush->renderBrushToTransferTexture(sin(g_frameCounter*0.06)*0.09 + g_mouseLoc.u,
                                          cos(g_frameCounter*0.06)*0.09 + g_mouseLoc.v);
  }
//  else
//  {
//    g_brush->renderBrushToTransferTexture(-600, -600);
//  }

  // liquid
//  for (unsigned int i=0; i!=4; ++i )
//  if (g_frameCounter % 2 == 0)
  {
    processLiquid();
  }
  visualize();


  glutSwapBuffers();
}
コード例 #14
0
ファイル: LargeVis.cpp プロジェクト: Cookies-gh/LargeVis-1
void LargeVis::run(long long out_d, long long n_thre, long long n_samp, long long n_prop, real alph, long long n_tree, long long n_nega, long long n_neig, real gamm, real perp)
{
	gsl_rng_env_setup();
	gsl_T = gsl_rng_rand48;
	gsl_r = gsl_rng_alloc(gsl_T);
	gsl_rng_set(gsl_r, 314159265);

	clean_model();
	if (!vec && !head)
	{
		printf("Missing training data!\n");
		return;
	}
	out_dim = out_d < 0 ? 2 : out_d;
	initial_alpha = alph < 0 ? 1.0 : alph;
	n_threads = n_thre < 0 ? 8 : n_thre;
	n_samples = n_samp;
	n_negatives = n_nega < 0 ? 5 : n_nega;
	n_neighbors = n_neig < 0 ? 150 : n_neig;
	n_trees = n_tree;
	n_propagations = n_prop < 0 ? 3 : n_prop;
	gamma = gamm < 0 ? 7.0 : gamm;
	perplexity = perp < 0 ? 50.0 : perp;
	if (n_samples < 0)
	{
		if (n_vertices < 10000)
			n_samples = 1000;
		else if (n_vertices < 1000000)
			n_samples = (n_vertices - 10000) * 9000 / (1000000 - 10000) + 1000;
		else n_samples = n_vertices / 100;
	}
	n_samples *= 1000000;
	if (n_trees < 0)
	{
		if (n_vertices < 100000)
			n_trees = 10;
		else if (n_vertices < 1000000)
			n_trees = 20;
		else if (n_vertices < 5000000)
			n_trees = 50;
		else n_trees = 100;
	}
	if (vec) { clean_graph(); construt_knn(); }
	visualize();
}
コード例 #15
0
int PCLKernel::execute()
{
    PointTable table;

    Stage& readerStage(makeReader(m_inputFile, ""));

    // go ahead and prepare/execute on reader stage only to grab input
    // PointViewSet, this makes the input PointView available to both the
    // processing pipeline and the visualizer
    readerStage.prepare(table);
    PointViewSet viewSetIn = readerStage.execute(table);

    // the input PointViewSet will be used to populate a BufferReader that is
    // consumed by the processing pipeline
    PointViewPtr input_view = *viewSetIn.begin();
    std::shared_ptr<BufferReader> bufferReader(new BufferReader);
    bufferReader->addView(input_view);

    Options filterOptions({"filename", m_pclFile});
    Stage& pclStage = makeFilter("filters.pclblock", *bufferReader,
        filterOptions);

    // the PCLBlock stage consumes the BufferReader rather than the
    // readerStage

    Options writerOptions;
    if (m_bCompress)
        writerOptions.add<bool>("compression", true);
    if (m_bForwardMetadata)
        writerOptions.add("forward_metadata", true);

    Stage& writer(makeWriter(m_outputFile, pclStage, "", writerOptions));

    writer.prepare(table);

    // process the data, grabbing the PointViewSet for visualization of the
    // resulting PointView
    PointViewSet viewSetOut = writer.execute(table);

    if (isVisualize())
        visualize(*viewSetOut.begin());
    //visualize(*viewSetIn.begin(), *viewSetOut.begin());

    return 0;
}
コード例 #16
0
void PropertyTimelineWidget::setFps(int fps) {
    QList<QGraphicsItem*> items = propertyTimelineScene_->items();
    for(int i = 0; i < items.size(); ++i) {
        if(dynamic_cast<QGraphicsLineItem*>(items.at(i)))
            propertyTimelineScene_->removeItem(items.at(i));
    }
    propertyTimelineScene_->addRect(0, 10, (int)AnimationEditor::getDuration(), 1);
    fps_ = fps;
    for(int x = 0; x < (int)AnimationEditor::getDuration(); x++) {        //add snaplines
            if(x % (2*fps) == 0) {
                propertyTimelineScene_->addLine(x, 3, x, 17);
            }
            else if(x % fps == 0) {
                propertyTimelineScene_->addLine(x, 5, x, 15);
            }
        }
    propertyTimelineView_->setSceneRect(-2,-2, duration_, 20);
    visualize();
}
コード例 #17
0
ファイル: visualizer.cpp プロジェクト: gijskant/mcrl2-pmc
void Visualizer::paintGL()
{
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();

  GLdouble aspect = (GLdouble)width() / (GLdouble)height();
  if (aspect > 1)
  {
    gluOrtho2D(aspect*(-1), aspect*1, -1, 1);
  }
  else
  {
    gluOrtho2D(-1, 1, (1/aspect)*(-1), (1/aspect)*1);
  }

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glViewport(0, 0, width(), height());

  visualize(m_inSelectMode);
  m_inSelectMode = false;
}
コード例 #18
0
ファイル: SortKernel.cpp プロジェクト: EricAlex/PDAL
int SortKernel::execute()
{
    Stage& readerStage = makeReader(m_inputFile, "");

    // go ahead and prepare/execute on reader stage only to grab input
    // PointViewSet, this makes the input PointView available to both the
    // processing pipeline and the visualizer
    PointTable table;
    readerStage.prepare(table);
    PointViewSet viewSetIn = readerStage.execute(table);

    // the input PointViewSet will be used to populate a BufferReader that is
    // consumed by the processing pipeline
    PointViewPtr inView = *viewSetIn.begin();

    BufferReader bufferReader;
    bufferReader.addView(inView);

    Stage& sortStage = makeFilter("filters.mortonorder", bufferReader);

    Stage& writer = makeWriter(m_outputFile, sortStage, "");
    Options writerOptions;
    if (m_bCompress)
        writerOptions.add("compression", true);
    if (m_bForwardMetadata)
        writerOptions.add("forward_metadata", true);
    writer.addOptions(writerOptions);

    writer.prepare(table);

    // process the data, grabbing the PointViewSet for visualization of the
    PointViewSet viewSetOut = writer.execute(table);

    if (isVisualize())
        visualize(*viewSetOut.begin());

    return 0;
}
コード例 #19
0
ファイル: RandomKernel.cpp プロジェクト: Rafaelaniemann/PDAL
int RandomKernel::execute()
{
    Options readerOptions;

    if (!m_bounds.empty())
        readerOptions.add("bounds", m_bounds);

    std::string distribution(Utils::tolower(m_distribution));
    if (distribution == "uniform")
        readerOptions.add("mode", "uniform");
    else if (distribution == "normal")
        readerOptions.add("mode", "normal");
    else if (distribution == "random")
        readerOptions.add("mode", "random");
    else
        throw pdal_error("invalid distribution: " + m_distribution);
    readerOptions.add("count", m_numPointsToWrite);

    Options writerOptions;
    if (m_bCompress)
        writerOptions.add("compression", true);

    Stage& reader = makeReader("", "readers.faux");
    reader.addOptions(readerOptions);

    Stage& writer = makeWriter(m_outputFile, reader, "");
    writer.addOptions(writerOptions);

    PointTable table;
    writer.prepare(table);
    PointViewSet viewSet = writer.execute(table);

    if (isVisualize())
        visualize(*viewSet.begin());

    return 0;
}
コード例 #20
0
ファイル: vectorize.c プロジェクト: Nekrofage/KomandoMap
void vectorize() 
{
	int x, y, i, start_ld_counter, old_ld_counter;

	for(y=0; y < DUNGEON_HGT; y++) {
		for(x=0; x < DUNGEON_WID; x++) {
			vertex_idx[y][x]=-1;
		}
	}

	for(y=0; y < DUNGEON_HGT - 1 ; y++) {
		for(x=0; x < DUNGEON_WID - 1; x++) {
			if(cave_sector_map[y][x] != cave_sector_map[y][x+1]) {
				max_linedefs++;
			}
			if(cave_sector_map[y][x] != cave_sector_map[y+1][x]) {
				max_linedefs++;
			}
		}
	}

	linedefs=(Linedef*)malloc((max_linedefs) * sizeof(Linedef));
	sidedefs=(Sidedef*)malloc((max_linedefs) * 2 * sizeof(Sidedef));

	sectors=(Sector*)malloc((sector_counter+1) * sizeof(Sector));

	for(i=0; i <= sector_counter; i++) {
		sectors[i].floor_height=0;
		sectors[i].ceiling_height=72;
		memset(sectors[i].floor_texture, 0, 8);
		memset(sectors[i].ceiling_texture, 0, 8);
		memcpy(sectors[i].floor_texture, "RROCK13", 7);
		memcpy(sectors[i].ceiling_texture, "RROCK13", 7);
		sectors[i].brightness=96;
		sectors[i].special=0;
		sectors[i].tag=-1;
	}

	for(y=0; y < DUNGEON_HGT - 1 ; y++) {
		for(x=0; x < DUNGEON_WID - 1; x++) {

			if(cave_sector_map[y][x] != cave_sector_map[y][x+1]) {
				do_linedef(y, x, y, x+1, 0);
			}

			if(cave_sector_map[y][x] != cave_sector_map[y+1][x]) {
				do_linedef(y, x, y+1, x, 1);
			}

			if(cave_feat[y][x]==FEAT_TRAP_HEAD) {
				sectors[cave_sector_map[y][x]].special += 0x10;
			}
		}		
	}

	vertexes=(Vertex*)malloc(vertex_counter * sizeof(Vertex));

	for(y=0; y < DUNGEON_HGT; y++) {
		for(x=0; x < DUNGEON_WID; x++) {
			if(vertex_idx[y][x] > -1) {
				vertexes[vertex_idx[y][x]].x = x * 64;
				vertexes[vertex_idx[y][x]].y = y * 64;
			}
		}
	}

	fflush(stdout);

	start_ld_counter=linedef_counter;
	do {
		old_ld_counter=linedef_counter;
		optimize_linedefs();
		fflush(stdout);
	} while(old_ld_counter != linedef_counter);


	visualize();
}
コード例 #21
0
ファイル: spDetectMex.cpp プロジェクト: lmhieu612/GOP
// inteface to various superpixel helpers
void mexFunction( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) {
  int f; char action[1024]; f=mxGetString(pr[0],action,1024); nr--; pr++;
  uint *S = (uint*) mxGetData(pr[0]);
  int h = (int) mxGetM(pr[0]);
  int w = (int) mxGetN(pr[0]);

  if(f) { mexErrMsgTxt("Failed to get action.");

  } else if(!strcmp(action,"sticky")) {
    // S = sticky( S, I, E, prm )
    float *I = (float*) mxGetData(pr[1]);
    float *E = (float*) mxGetData(pr[2]);
    double *prm = (double*) mxGetData(pr[3]);
    pl[0] = mxCreateNumericMatrix(h,w,mxUINT32_CLASS,mxREAL);
    uint* T = (uint*) mxGetData(pl[0]); memcpy(T,S,h*w*sizeof(uint));
    sticky(T,h,w,I,E,prm); relabel(T,h,w);

  } else if(!strcmp(action,"boundaries")) {
    // S = boundaries( S, E, add, nThreads )
    float *E = (float*) mxGetData(pr[1]);
    bool add = mxGetScalar(pr[2])>0;
    uint nThreads = (uint) mxGetScalar(pr[3]);
    pl[0] = mxCreateNumericMatrix(h,w,mxUINT32_CLASS,mxREAL);
    uint* T = (uint*) mxGetData(pl[0]); memcpy(T,S,h*w*sizeof(uint));
    boundaries(T,h,w,E,add,nThreads);

  } else if(!strcmp(action,"merge")) {
    // S = merge( S, E, thr );
    float *E = (float*) mxGetData(pr[1]);
    float thr = (float) mxGetScalar(pr[2]);
    pl[0] = mxCreateNumericMatrix(h,w,mxUINT32_CLASS,mxREAL);
    uint* T = (uint*) mxGetData(pl[0]); memcpy(T,S,h*w*sizeof(uint));
    merge(T,h,w,E,thr);

  } else if(!strcmp(action,"visualize")) {
    // V = visualize( S, I, hasBnds )
    float *I = (float*) mxGetData(pr[1]);
    bool hasBnds = mxGetScalar(pr[2])>0;
    const int dims[3] = {h,w,3};
    pl[0] = mxCreateNumericArray(3,dims,mxSINGLE_CLASS,mxREAL);
    float* V = (float*) mxGetData(pl[0]);
    visualize(V,S,h,w,I,hasBnds);

  } else if(!strcmp(action,"affinities")) {
    // A = affinities( S, E, segs, nThreads )
    float *E  = (float*) mxGetData(pr[1]);
    uint8 *segs  = (uint8*) mxGetData(pr[2]);
    uint nThreads = (uint) mxGetScalar(pr[3]);
    if( mxGetNumberOfDimensions(pr[2])!=5 ) mexErrMsgTxt("invalid input");
    uint *dims = (uint*) mxGetDimensions(pr[2]);
    uint m=0; for( uint x=0; x<w*h; x++ ) m=S[x]>m ? S[x] : m;
    pl[0] = mxCreateNumericMatrix(m,m,mxSINGLE_CLASS,mxREAL);
    float *A = (float*) mxGetData(pl[0]);
    affinities(A,S,h,w,E,segs,dims,nThreads);

  } else if(!strcmp(action,"edges")) {
    // E = edges(S,A);
    float* A = (float*) mxGetData(pr[1]);
    pl[0] = mxCreateNumericMatrix(h,w,mxSINGLE_CLASS,mxREAL);
    float *E = (float*) mxGetData(pl[0]);
    edges(E,S,h,w,A);

  } else mexErrMsgTxt("Invalid action.");
}
コード例 #22
0
ファイル: SortKernel.cpp プロジェクト: devrimgunduz/PDAL
int SortKernel::execute()
{
    PointTable table;

    Options readerOptions;
    readerOptions.add("filename", m_inputFile);
    readerOptions.add("debug", isDebug());
    readerOptions.add("verbose", getVerboseLevel());

    Stage& readerStage = makeReader(readerOptions);

    // go ahead and prepare/execute on reader stage only to grab input
    // PointViewSet, this makes the input PointView available to both the
    // processing pipeline and the visualizer
    readerStage.prepare(table);
    PointViewSet viewSetIn = readerStage.execute(table);

    // the input PointViewSet will be used to populate a BufferReader that is
    // consumed by the processing pipeline
    PointViewPtr inView = *viewSetIn.begin();

    BufferReader bufferReader;
    bufferReader.setOptions(readerOptions);
    bufferReader.addView(inView);

    Options sortOptions;
    sortOptions.add<bool>("debug", isDebug());
    sortOptions.add<uint32_t>("verbose", getVerboseLevel());

    StageFactory f;
    Stage& sortStage = ownStage(f.createStage("filters.mortonorder"));
    sortStage.setInput(bufferReader);
    sortStage.setOptions(sortOptions);

    Options writerOptions;
    writerOptions.add("filename", m_outputFile);
    setCommonOptions(writerOptions);

    if (m_bCompress)
        writerOptions.add("compression", true);
    if (m_bForwardMetadata)
        writerOptions.add("forward_metadata", true);

    std::vector<std::string> cmd = getProgressShellCommand();
    UserCallback *callback =
        cmd.size() ? (UserCallback *)new ShellScriptCallback(cmd) :
        (UserCallback *)new HeartbeatCallback();

    Stage& writer = makeWriter(m_outputFile, sortStage);

    // Some options are inferred by makeWriter based on filename
    // (compression, driver type, etc).
    writer.setOptions(writerOptions + writer.getOptions());
    writer.setUserCallback(callback);

    for (const auto& pi : getExtraStageOptions())
    {
        std::string name = pi.first;
        Options options = pi.second;
        //ABELL - Huh?
        std::vector<Stage *> stages = writer.findStage(name);
        for (const auto& s : stages)
        {
            Options opts = s->getOptions();
            for (const auto& o : options.getOptions())
                opts.add(o);
            s->setOptions(opts);
        }
    }
    writer.prepare(table);

    // process the data, grabbing the PointViewSet for visualization of the
    PointViewSet viewSetOut = writer.execute(table);

    if (isVisualize())
        visualize(*viewSetOut.begin());

    return 0;
}
コード例 #23
0
ファイル: Ground.cpp プロジェクト: pramsey/PDAL
int Ground::execute()
{
    PointContext ctx;

    Options readerOptions;
    readerOptions.add<std::string>("filename", m_inputFile);
    readerOptions.add<bool>("debug", isDebug());
    readerOptions.add<boost::uint32_t>("verbose", getVerboseLevel());

    std::unique_ptr<Stage> readerStage = makeReader(readerOptions);

    // go ahead and prepare/execute on reader stage only to grab input
    // PointBufferSet, this makes the input PointBuffer available to both the
    // processing pipeline and the visualizer
    readerStage->prepare(ctx);
    PointBufferSet pbSetIn = readerStage->execute(ctx);

    // the input PointBufferSet will be used to populate a BufferReader that is
    // consumed by the processing pipeline
    PointBufferPtr input_buffer = *pbSetIn.begin();
    BufferReader bufferReader;
    bufferReader.setOptions(readerOptions);
    bufferReader.addBuffer(input_buffer);

    Options groundOptions;
    std::ostringstream ss;
    ss << "{";
    ss << "  \"pipeline\": {";
    ss << "    \"filters\": [{";
    ss << "      \"name\": \"ProgressiveMorphologicalFilter\",";
    ss << "      \"setMaxWindowSize\": " << m_maxWindowSize << ",";
    ss << "      \"setSlope\": " << m_slope << ",";
    ss << "      \"setMaxDistance\": " << m_maxDistance << ",";
    ss << "      \"setInitialDistance\": " << m_initialDistance << ",";
    ss << "      \"setCellSize\": " << m_cellSize << ",";
    ss << "      \"setBase\": " << m_base << ",";
    ss << "      \"setExponential\": " << m_exponential;
    ss << "      }]";
    ss << "    }";
    ss << "}";
    std::string json = ss.str();
    groundOptions.add<std::string>("json", json);
    groundOptions.add<bool>("debug", isDebug());
    groundOptions.add<boost::uint32_t>("verbose", getVerboseLevel());

    std::unique_ptr<Stage> groundStage(new filters::PCLBlock());
    groundStage->setInput(&bufferReader);
    groundStage->setOptions(groundOptions);

    // the PCLBlock groundStage consumes the BufferReader rather than the
    // readerStage
    groundStage->setInput(&bufferReader);

    Options writerOptions;
    writerOptions.add<std::string>("filename", m_outputFile);
    setCommonOptions(writerOptions);

    std::unique_ptr<Writer> writer(AppSupport::makeWriter(m_outputFile, groundStage.get()));
    writer->setOptions(writerOptions);

    std::vector<std::string> cmd = getProgressShellCommand();
    UserCallback *callback =
        cmd.size() ? (UserCallback *)new ShellScriptCallback(cmd) :
        (UserCallback *)new HeartbeatCallback();

    writer->setUserCallback(callback);

    for (auto pi: getExtraStageOptions())
    {
        std::string name = pi.first;
        Options options = pi.second;
        std::vector<Stage*> stages = writer->findStage(name);
        for (auto s: stages)
        {
            Options opts = s->getOptions();
            for (auto o: options.getOptions())
                opts.add(o);
            s->setOptions(opts);
        }
    }

    writer->prepare(ctx);

    // process the data, grabbing the PointBufferSet for visualization of the
    // resulting PointBuffer
    PointBufferSet pbSetOut = writer->execute(ctx);

    if (isVisualize())
        visualize(*pbSetOut.begin());
    //visualize(*pbSetIn.begin(), *pbSetOut.begin());

    return 0;
}
コード例 #24
0
ファイル: darknet.c プロジェクト: imaami/darknet
int main(int argc, char **argv)
{
    //test_resize("data/bad.jpg");
    //test_box();
    //test_convolutional_layer();
    if(argc < 2){
        fprintf(stderr, "usage: %s <function>\n", argv[0]);
        return 0;
    }
    gpu_index = find_int_arg(argc, argv, "-i", 0);
    if(find_arg(argc, argv, "-nogpu")) {
        gpu_index = -1;
    }

#ifndef GPU
    gpu_index = -1;
#else
    if(gpu_index >= 0){
        cudaError_t status = cudaSetDevice(gpu_index);
        check_error(status);
    }
#endif

    if(0==strcmp(argv[1], "imagenet")){
        run_imagenet(argc, argv);
    } else if (0 == strcmp(argv[1], "average")){
        average(argc, argv);
    } else if (0 == strcmp(argv[1], "yolo")){
        run_yolo(argc, argv);
    } else if (0 == strcmp(argv[1], "cifar")){
        run_cifar(argc, argv);
    } else if (0 == strcmp(argv[1], "go")){
        run_go(argc, argv);
    } else if (0 == strcmp(argv[1], "rnn")){
        run_char_rnn(argc, argv);
    } else if (0 == strcmp(argv[1], "vid")){
        run_vid_rnn(argc, argv);
    } else if (0 == strcmp(argv[1], "coco")){
        run_coco(argc, argv);
    } else if (0 == strcmp(argv[1], "classifier")){
        run_classifier(argc, argv);
    } else if (0 == strcmp(argv[1], "tag")){
        run_tag(argc, argv);
    } else if (0 == strcmp(argv[1], "compare")){
        run_compare(argc, argv);
    } else if (0 == strcmp(argv[1], "dice")){
        run_dice(argc, argv);
    } else if (0 == strcmp(argv[1], "writing")){
        run_writing(argc, argv);
    } else if (0 == strcmp(argv[1], "test")){
        test_resize(argv[2]);
    } else if (0 == strcmp(argv[1], "captcha")){
        run_captcha(argc, argv);
    } else if (0 == strcmp(argv[1], "nightmare")){
        run_nightmare(argc, argv);
    } else if (0 == strcmp(argv[1], "change")){
        change_rate(argv[2], atof(argv[3]), (argc > 4) ? atof(argv[4]) : 0);
    } else if (0 == strcmp(argv[1], "rgbgr")){
        rgbgr_net(argv[2], argv[3], argv[4]);
    } else if (0 == strcmp(argv[1], "denormalize")){
        denormalize_net(argv[2], argv[3], argv[4]);
    } else if (0 == strcmp(argv[1], "normalize")){
        normalize_net(argv[2], argv[3], argv[4]);
    } else if (0 == strcmp(argv[1], "rescale")){
        rescale_net(argv[2], argv[3], argv[4]);
    } else if (0 == strcmp(argv[1], "partial")){
        partial(argv[2], argv[3], argv[4], atoi(argv[5]));
    } else if (0 == strcmp(argv[1], "stacked")){
        stacked(argv[2], argv[3], argv[4]);
    } else if (0 == strcmp(argv[1], "visualize")){
        visualize(argv[2], (argc > 3) ? argv[3] : 0);
    } else if (0 == strcmp(argv[1], "imtest")){
        test_resize(argv[2]);
    } else {
        fprintf(stderr, "Not an option: %s\n", argv[1]);
    }
    return 0;
}
コード例 #25
0
ファイル: SmoothKernel.cpp プロジェクト: FeodorFitsner/PDAL
int SmoothKernel::execute()
{
    PointTable table;

    Options readerOptions;
    readerOptions.add("filename", m_inputFile);
    setCommonOptions(readerOptions);

    Stage& readerStage(Kernel::makeReader(m_inputFile));
    readerStage.setOptions(readerOptions);

    // go ahead and prepare/execute on reader stage only to grab input
    // PointViewSet, this makes the input PointView available to both the
    // processing pipeline and the visualizer
    readerStage.prepare(table);
    PointViewSet viewSetIn = readerStage.execute(table);

    // the input PointViewSet will be used to populate a BufferReader that is
    // consumed by the processing pipeline
    PointViewPtr input_view = *viewSetIn.begin();
    std::shared_ptr<BufferReader> bufferReader(new BufferReader);
    bufferReader->setOptions(readerOptions);
    bufferReader->addView(input_view);

    Options smoothOptions;
    std::ostringstream ss;
    ss << "{";
    ss << "  \"pipeline\": {";
    ss << "    \"filters\": [{";
    ss << "      \"name\": \"MovingLeastSquares\"";
    ss << "      }]";
    ss << "    }";
    ss << "}";
    std::string json = ss.str();
    smoothOptions.add("json", json);
    smoothOptions.add("debug", isDebug());
    smoothOptions.add("verbose", getVerboseLevel());

    auto& smoothStage = createStage("filters.pclblock");
    smoothStage.setOptions(smoothOptions);
    smoothStage.setInput(*bufferReader);

    Options writerOptions;
    writerOptions.add("filename", m_outputFile);
    setCommonOptions(writerOptions);

    Stage& writer(Kernel::makeWriter(m_outputFile, smoothStage));
    writer.setOptions(writerOptions);

    writer.prepare(table);

    // process the data, grabbing the PointViewSet for visualization of the
    // resulting PointView
    PointViewSet viewSetOut = writer.execute(table);

    if (isVisualize())
        visualize(*viewSetOut.begin());
    //visualize(*viewSetIn.begin(), *viewSetOut.begin());

    return 0;
}
コード例 #26
0
ファイル: main.cpp プロジェクト: apqw/epi
int main(int argc,char** argv){
    cmdline::parser cp;
    const std::string udelim = "\n\t\t";
    cp.add<std::string>("mode", 'm',
        "Specify a mode shown below."_s+udelim+
        "c:Calculate with CPU. Need --cparam,--input" + udelim +
        "g:Calculate with GPU. Need --cparam,--input" + udelim +
        "v:Visualize the result.Need --cparam,--vparam" + udelim +
        "d:Diff calc parameter file. Need --cparam,--cparam2" + udelim +
        "gp:Generate default parameter files. Use --cparam,--vparam for output."+udelim+
        "i:Generate initial cell data file.Need --cparam,--output");
    cp.add<std::string>("input", 'i', "Cell data file.", false);
    cp.add<std::string>("output",'o', "Cell data output file(for init)",false);
    cp.add<std::string>("cparam", '\0', "Specify an parameter file path for calculation.",false);
    cp.add<std::string>("cparam2", '\0', "Additional parameter file (for diff)",false);
    cp.add<std::string>("vparam", '\0', "Specify an parameter file path for visualization.",false);
    cp.add<std::string>("initial", '\0', "Start calculation with initial state (without specifying initial data file)",false);
    cp.parse_check(argc, argv);
    auto mode = cp.get<std::string>("mode");
    bool is_gpu = mode == "g";
    bool is_vis = mode == "v";
    bool is_cpu = mode == "c";
    bool is_diff = mode == "d";
    bool is_gen = mode == "gp";
    bool is_init = mode == "i";

    static void* aptr = malloc(sizeof(const CalcParams));
    auto EH = ErrorHandling(cp);

    if(is_init){
    	EH.check("cparam","output");
    	set_param(cp,aptr);
    	try{
    	init_gen_output(cp.get<std::string>("output"),16,8);
    	}catch(std::exception& e){
    		  std::cerr << e.what() << std::endl;
    		            std::exit(1);
    	}

    }
    if (is_gen) {
        if (cp.exist("cparam")) {
            std::cout << "Generate cparam as " << cp.get<std::string>("cparam")  << std::endl;
            CalcParams().generate_paramfile(cp.get<std::string>("cparam"));
        }

        if (cp.exist("vparam")) {
            std::cout << "Generate vparam as " << cp.get<std::string>("vparam") << std::endl;
            VisParams().generate_paramfile(cp.get<std::string>("vparam"));
        }

    }
    if (is_diff) {
    	EH.check("cparam","cparam2");
        try {
            const CalcParams cp1 = CalcParams(cp.get<std::string>("cparam"));
            const CalcParams cp2 = CalcParams(cp.get<std::string>("cparam2"));
            std::cout << "Compare " << cp.get<std::string>("cparam") << " and " << cp.get<std::string>("cparam2") <<std::endl;
            CalcParams::diff(cp1, cp2);
        }
        catch (std::exception& e) {
            std::cerr << e.what() << std::endl;
            std::exit(1);
        }
    }
    if (is_cpu || is_gpu) {
    	const bool init_exist=cp.exist("initial");
    	if(init_exist){
    		EH.check("cparam");
    	}else{
    		EH.check("cparam","input");
    	}
    	set_param(cp,aptr);
        CellManager cman;

        try {
            if(init_exist){
            	auto inum=parse_init_setting(cp.get<std::string>("initial"));
            	cman=init_gen(std::get<0>(inum),std::get<1>(inum));
            }else{
            cman.load(cp.get<std::string>("input"));
            }
        }
        catch (std::exception& e) {
            std::cerr << e.what() << std::endl;
            std::exit(1);
        }
        //connect_cell(cman);
        calc_with_cpu(cman);
    }

    if (is_vis) {
       EH.check("cparam","vparam");
       set_param(cp,aptr);
        try {
            VisParams vp(cp.get<std::string>("vparam"));
            init_visualizer(&argc, argv,vp);
            visualize();
        }
        catch (std::exception& e) {
            std::cerr << e.what() << std::endl;
            std::exit(1);
        }
    }




	std::cout<<"Done."<<std::endl;
}
コード例 #27
0
ファイル: PCLKernel.cpp プロジェクト: rskelly/PDAL
int PCLKernel::execute()
{
    PointContext ctx;

    Options readerOptions;
    readerOptions.add<std::string>("filename", m_inputFile);
    readerOptions.add<bool>("debug", isDebug());
    readerOptions.add<uint32_t>("verbose", getVerboseLevel());

    std::unique_ptr<Stage> readerStage = makeReader(readerOptions);

    // go ahead and prepare/execute on reader stage only to grab input
    // PointBufferSet, this makes the input PointBuffer available to both the
    // processing pipeline and the visualizer
    readerStage->prepare(ctx);
    PointBufferSet pbSetIn = readerStage->execute(ctx);

    // the input PointBufferSet will be used to populate a BufferReader that is
    // consumed by the processing pipeline
    PointBufferPtr input_buffer = *pbSetIn.begin();
    BufferReader bufferReader;
    bufferReader.addBuffer(input_buffer);

    Options pclOptions;
    pclOptions.add<std::string>("filename", m_pclFile);
    pclOptions.add<bool>("debug", isDebug());
    pclOptions.add<uint32_t>("verbose", getVerboseLevel());

    std::unique_ptr<Stage> pclStage(new filters::PCLBlock());
    pclStage->setInput(&bufferReader);
    pclStage->setOptions(pclOptions);

    // the PCLBlock stage consumes the BufferReader rather than the
    // readerStage

    Options writerOptions;
    writerOptions.add<std::string>("filename", m_outputFile);
    setCommonOptions(writerOptions);

    if (m_bCompress)
        writerOptions.add<bool>("compression", true);
    if (m_bForwardMetadata)
        writerOptions.add("forward_metadata", true);

    std::vector<std::string> cmd = getProgressShellCommand();
    UserCallback *callback =
        cmd.size() ? (UserCallback *)new ShellScriptCallback(cmd) :
        (UserCallback *)new HeartbeatCallback();

    WriterPtr
        writer(KernelSupport::makeWriter(m_outputFile, pclStage.get()));

    // Some options are inferred by makeWriter based on filename
    // (compression, driver type, etc).
    writer->setOptions(writerOptions+writer->getOptions());

    writer->setUserCallback(callback);

    for (const auto& pi : getExtraStageOptions())
    {
        std::string name = pi.first;
        Options options = pi.second;
        std::vector<Stage*> stages = writer->findStage(name);
        for (const auto& s : stages)
        {
            Options opts = s->getOptions();
            for (const auto& o : options.getOptions())
                opts.add(o);
            s->setOptions(opts);
        }
    }

    writer->prepare(ctx);

    // process the data, grabbing the PointBufferSet for visualization of the
    // resulting PointBuffer
    PointBufferSet pbSetOut = writer->execute(ctx);

    if (isVisualize())
        visualize(*pbSetOut.begin());
    //visualize(*pbSetIn.begin(), *pbSetOut.begin());

    return 0;
}
コード例 #28
0
int main(int argc, char *argv[])
{
	int afd = -1, pfd, pfd2 = -1;
	short buf[8192];
	short buf2[16384];
	char  output_file[255];
	int res, res2;
	int visual = 0;
	int x,i;
	struct zt_confinfo zc;

	if ((argc < 2) || (atoi(argv[1]) < 1)) {
		fprintf(stderr, "Usage: ztmonitor <channel num> [-v[v]] [-f FILE]\n");
		exit(1);
	}
	for (i = 2; i < argc; ++i) {
		if (!strcmp(argv[i], "-v")) {
				if (visual)
					verbose = 1;
		        visual = 1;
		} else if (!strcmp(argv[i], "-vv")) {
			visual = 1;
			verbose = 1;
       	} else if (!strcmp(argv[i], "-f") && (i+1) < argc) {
			++i; /*we care about hte file name */
			if (strlen(argv[i]) < 255 ) {
				strcpy(output_file, argv[i]);
				fprintf(stderr, "Output to %s\n", output_file);
				if ((ofh = fopen(output_file, "w"))<0) {
					fprintf(stderr, "Could not open %s for writing: %s\n", output_file, strerror(errno));
					exit(0);
				}
				fprintf(stderr, "Run e.g., 'sox -r 8000 -s -w -c 1 file.raw file.wav' to convert.\n");
			} else {
				fprintf(stderr, "File Name %s too long\n",argv[i+1]);
			}
		}
	}
	if (!visual) {
		/* Open audio */
		if ((afd = audio_open()) < 0) {
			printf("Cannot open audio ...\n");
			if (!ofh) exit(0);
		}
	}
	/* Open Pseudo device */
	if ((pfd = pseudo_open()) < 0)
		exit(1);
	if (visual && ((pfd2 = pseudo_open()) < 0))
		exit(1);
	/* Conference them */
	memset(&zc, 0, sizeof(zc));
	zc.chan = 0;
	zc.confno = atoi(argv[1]);
	if (visual) {
		/* Two pseudo's, one for tx, one for rx */
		zc.confmode = ZT_CONF_MONITORTX;
		if (ioctl(pfd, ZT_SETCONF, &zc) < 0) {
			fprintf(stderr, "Unable to monitor: %s\n", strerror(errno));
			exit(1);
		}
		memset(&zc, 0, sizeof(zc));
		zc.chan = 0;
		zc.confno = atoi(argv[1]);
		zc.confmode = ZT_CONF_MONITOR;
		if (ioctl(pfd2, ZT_SETCONF, &zc) < 0) {
			fprintf(stderr, "Unable to monitor: %s\n", strerror(errno));
			exit(1);
		}
	} else {
		zc.confmode = ZT_CONF_MONITORBOTH;
		if (ioctl(pfd, ZT_SETCONF, &zc) < 0) {
			fprintf(stderr, "Unable to monitor: %s\n", strerror(errno));
			exit(1);
		}
	}
	if (visual) {
		printf("\nVisual Audio Levels.\n");
		printf("--------------------\n");
		printf(" Use zapata.conf file to adjust the gains if needed.\n\n");
		printf("( # = Audio Level  * = Max Audio Hit )\n");
		draw_barheader();
	}
	/* Now, copy from pseudo to audio */
	for (;;) {
		res = read(pfd, buf, sizeof(buf));
		if (res < 1) 
			break;
		if (visual) {
			res2 = read(pfd2, buf2, res);
			if (res2 < 1) 
				break;
			if (res == res2)
				visualize((short *)buf, (short *)buf2, res/2);
			else
				printf("Huh?  res = %d, res2 = %d?\n", res, res2);
			
		} else {
			if (ofh)	        
				fwrite(buf, 1, res, ofh);
		 	if (afd) {
				if (stereo) {
					for (x=0;x<res;x++)
						buf2[x<<1] = buf2[(x<<1) + 1] = buf[x];
					write(afd, buf2, res << 1);
				} else
					write(afd, buf, res);
			}
		}
	}
	if (ofh) fclose(ofh); /*Never Reached */
	exit(0);
}
コード例 #29
0
ファイル: SmoothKernel.cpp プロジェクト: rskelly/PDAL
int SmoothKernel::execute()
{
    PointContext ctx;

    Options readerOptions;
    readerOptions.add("filename", m_inputFile);
    readerOptions.add("debug", isDebug());
    readerOptions.add("verbose", getVerboseLevel());

    std::unique_ptr<Stage> readerStage = makeReader(readerOptions);

    // go ahead and prepare/execute on reader stage only to grab input
    // PointBufferSet, this makes the input PointBuffer available to both the
    // processing pipeline and the visualizer
    readerStage->prepare(ctx);
    PointBufferSet pbSetIn = readerStage->execute(ctx);

    // the input PointBufferSet will be used to populate a BufferReader that is
    // consumed by the processing pipeline
    PointBufferPtr input_buffer = *pbSetIn.begin();
    BufferReader bufferReader;
    bufferReader.setOptions(readerOptions);
    bufferReader.addBuffer(input_buffer);

    Options smoothOptions;
    std::ostringstream ss;
    ss << "{";
    ss << "  \"pipeline\": {";
    ss << "    \"filters\": [{";
    ss << "      \"name\": \"MovingLeastSquares\"";
    ss << "      }]";
    ss << "    }";
    ss << "}";
    std::string json = ss.str();
    smoothOptions.add("json", json);
    smoothOptions.add("debug", isDebug());
    smoothOptions.add("verbose", getVerboseLevel());

    std::unique_ptr<Stage> smoothStage(new filters::PCLBlock());
    smoothStage->setOptions(smoothOptions);
    smoothStage->setInput(&bufferReader);

    Options writerOptions;
    writerOptions.add("filename", m_outputFile);
    setCommonOptions(writerOptions);

    WriterPtr writer(KernelSupport::makeWriter(m_outputFile, smoothStage.get()));
    writer->setOptions(writerOptions);

    std::vector<std::string> cmd = getProgressShellCommand();
    UserCallback *callback =
        cmd.size() ? (UserCallback *)new ShellScriptCallback(cmd) :
        (UserCallback *)new HeartbeatCallback();

    writer->setUserCallback(callback);

    std::map<std::string, Options> extra_opts = getExtraStageOptions();
    std::map<std::string, Options>::iterator pi;
    for (pi = extra_opts.begin(); pi != extra_opts.end(); ++pi)
    {
        std::string name = pi->first;
        Options options = pi->second;
        std::vector<Stage*> stages = writer->findStage(name);
        std::vector<Stage*>::iterator s;
        for (s = stages.begin(); s != stages.end(); ++s)
        {
            Options opts = (*s)->getOptions();
            std::vector<Option>::iterator o;
            for (o = options.getOptions().begin(); o != options.getOptions().end(); ++o)
                opts.add(*o);
            (*s)->setOptions(opts);
        }
    }

    writer->prepare(ctx);

    // process the data, grabbing the PointBufferSet for visualization of the
    // resulting PointBuffer
    PointBufferSet pbSetOut = writer->execute(ctx);

    if (isVisualize())
        visualize(*pbSetOut.begin());
    //visualize(*pbSetIn.begin(), *pbSetOut.begin());

    return 0;
}
コード例 #30
0
void * launch_visualize(void * v_struct){
  visualizer_struct * arg = (visualizer_struct *) v_struct;
  visualize(arg->visited, arg->size);
}