Example #1
0
void init(){
  glfwInit();
  
  ctx = new libfreenect2::Freenect2;
  listener = new libfreenect2::SyncMultiFrameListener(libfreenect2::Frame::Color 
                                                      | libfreenect2::Frame::Ir 
                                                      | libfreenect2::Frame::Depth); 
  frames = new libfreenect2::FrameMap;

  dev = ctx->openDefaultDevice();

  if(!dev){
    throw ICLException("no device connected or failure opening the default one!");
  }
  
  dev->setColorFrameListener(listener);
  dev->setIrAndDepthFrameListener(listener);
  dev->start();

  std::cout << "device serial: " << dev->getSerialNumber() << std::endl;
  std::cout << "device firmware: " << dev->getFirmwareVersion() << std::endl;

  gui << ( VBox() 
           << Image().handle("hdepth").minSize(10,8)
           << Image().handle("hcolor").minSize(10,8)
           << Image().handle("hir").minSize(10,8)
         )
      << ( HSplit() 
           << Draw3D().handle("draw3D").minSize(40,30)
           )
      << Show();
}
Example #2
0
void init(){
  grabber.init(pa("-i"));

  bool c_arg = pa("-c");

  gui << Draw().handle("draw").label("input image")
      << Image().handle("cropped").label("cropped")
      << ( VBox().maxSize(c_arg ? 0 : 12,99).minSize(c_arg ? 0 : 12,1)
           << Button("save as ..").handle("saveAs")
           << Button("overwrite input").handle("overwrite")
           << Combo("0,90,180,270").handle("rot").label("rotation")
           << CheckBox("rectangular",!pa("-r")).handle("rect")
           << Button("Batch crop...").handle("batch")
           << ( HBox().label("rectification size")
                << Spinner(1,4096,640).handle("s1")
                << Label(":")
                << Spinner(1,4096,480).handle("s2")
                )
           << (HBox() 
               << Fps().handle("fps")
               << CamCfg()
               )
           )
      << Show();


  if(!c_arg){
    gui["batch"].registerCallback(batch_crop);
  }
  const ImgBase *image = grabber.grab();
  if(!c_arg){
    mouse_1 = new Mouse1(image->getSize());
    gui["draw"].install(mouse_1);
  }
  mouse_2 = new Mouse2(image->getSize());
  gui["draw"].install(mouse_2);
  
  DrawHandle draw = gui["draw"];
  draw->setImageInfoIndicatorEnabled(false);
  
  if(!c_arg){
    gui["rect"].registerCallback(rectangular_changed);
    rectangular_changed();
    if(*pa("-i",0) != "file" || FileList(*pa("-i",1)).size() != 1){
      gui["overwrite"].disable();
    }else{
      gui["overwrite"].registerCallback(overwrite);
    }
    gui["saveAs"].registerCallback(save_as);
  }

}
Example #3
0
void batch_crop(){
  if(!batchGUI){
    batchGUI = new HSplit;
    (*batchGUI) << ( VBox()
                     << String("").handle("ipat").label("input file pattern")
                     << String("converted-####.png").handle("opat").label("output file pattern")
                     << Button("do it!").handle("do it")
                   )
                << VScroll().handle("matches").label("matching files")
                << Create();
    (*batchGUI)["ipat"].registerCallback(batch_pattern_changed<false>);
    (*batchGUI)["do it"].registerCallback(batch_pattern_changed<true>);
  }
  (*batchGUI).show();
}
Example #4
0
void init(){
  int masksize = 10;
  int thresh = 2;
  float gamma = 0;
  if(pa("-config")){
    ConfigFile f(*pa("-config"));
    masksize = f["config.masksize"];
    thresh = f["config.threshold"];
    gamma = f["config.gammaslope"];
  }

  gui << Draw().minSize(16,12).handle("orig").label("original image")
      << Image().minSize(16,12).handle("prev").label("preview image")
      << ( VBox().label("controls")
           << Slider(2,200,masksize).label("mask size").out("masksize").minSize(15,2).handle("a")
           << FSlider(-30,40,thresh).label("threshold").out("threshold").minSize(15,2).handle("b")
           << FSlider(0,15,gamma).label("gamma slope").out("gamma").minSize(15,2).handle("c")
           << Button("next image").handle("next")
           << Button("stopped","running").out("loop").handle("d")
           << Button("no clip","clip to roi").out("clipToROI").handle("e")
           << Button("save params").handle("save")
           << Combo("region mean,tiledNN,tiledLIN").handle("algorithm").label("algorithm")
           << ( HBox()
                << Label("..ms").handle("time").label("apply time").minSize(2,3)
                << Fps(10).handle("fps").minSize(4,3).label("fps")
                )
           )
      << Show();
  
  grabber.init(pa("-i"));
  if(grabber.getType() != "file"){
    grabber.useDesired<Size>(pa("-s"));
    if(!pa("-color")){
      grabber.useDesired(formatGray);
    }else{
      grabber.useDesired(formatRGB);
    }
    grabber.useDesired(depth8u);
  }
  
  gui.registerCallback(step,"a,b,c,d,e,next,algorithm");
  gui["orig"].install(new MouseHandler(mouse));
  
  step();
}
Example #5
0
void init() {

	grabber.init(pa("-i"));

	if (pa("-s")) {
		utils::Size size = pa("-s");
		grabber.setDesiredSizeInternal(size);
	}

    // create the GUI
	gui << ( VBox()
			 << ( HBox()
				  << Draw().label("Original").handle("view1").minSize(16, 12)
				  << Draw().label("Median").handle("view2").minSize(16, 12)
				  << Draw().label("Bilateral Filtered").handle("view3").minSize(16, 12)
				  )
			 << ( HBox()
				  << Draw().label("Original").handle("viewedge1").minSize(16, 12)
				  << Draw().label("Median").handle("viewedge2").minSize(16, 12)
				  << Draw().label("Bilateral Filtered").handle("viewedge3").minSize(16, 12)
				  )
			 << CheckBox("Use LAB",true).handle("use_lab")
			 << CheckBox("Use gray image",false).handle("to_gray")
			 << Slider(1,24,4).label("Bilateral Kernel Radius").handle("bi_radius")
			 << Slider(1,24,4).label("Median Kernel Radius").handle("median_radius")
			 << FSlider(0.1,200,5).label("sigma_r (bilateral) ").handle("sigma_r")
			 << FSlider(0.1,200,5).label("sigma_s (bilateral) ").handle("sigma_s")
			 << Slider(0,255,200).label("Canny low th").handle("canny_low_th")
			 << Slider(0,255,255).label("Canny high th").handle("canny_high_th")
			 << Slider(10,100,100).label("ROI of Img (Percent)").handle("roi_size")
			 << Fps().handle("fps")
			 );
    gui << Show();

	bi_filter = new BilateralFilterOp();

}
Example #6
0
void init(){

  //  scene.getLight(0).setOn(false);
  scene.getLight(0).setDiffuse(GeomColor(255,255,255,50));

  SceneLight &l = scene.getLight(1);
  static Camera cam(Vec(0,0,600,1),
                    Vec(0,0,-1,1),
                    Vec(0,-1,0,1));
  cam.setResolution(Size(1024,1024));
  scene.setGravity(Vec(0,0,-1000));

  l.setShadowCam(new Camera(cam));
  l.setShadowEnabled(true);
  l.setAnchorToWorld();
  l.setPosition(Vec(0,0,600,1));
  l.setOn(true);
  l.setSpecularEnabled(true);
  l.setDiffuseEnabled(true);
  l.setSpecular(GeomColor(0,100,255,255));
  l.setDiffuse(GeomColor(255,100,0,30));

  scene.setPropertyValue("shadows.use improved shading",true);
  scene.setPropertyValue("shadows.resolution",2048);
  scene.setPropertyValue("shadows.bias",10);


  //static const int W=20,H=13,DIM=W*H;
  static const int W=pa("-paper-dim",0), H=pa("-paper-dim",1);
  static Img8u frontFace = load<icl8u>(*pa("-ff"));
  static Img8u backFace = load<icl8u>(*pa("-bf"));

  const Size s(210,297);
  const Vec corners[4] = {
    Vec(-s.width/2, -s.height/2, 150,1),
    Vec(s.width/2, -s.height/2, 150,1),
    Vec(s.width/2, s.height/2, 150,1),
    Vec(-s.width/2, s.height/2, 150,1),
  };

  paper = new ManipulatablePaper(&scene,&scene,W,H,corners,true,&frontFace,&backFace);
  //scene.removeObject(paper);
  //paper->addShadow(-74.5);


  if(pa("-o")){
    std::vector<Camera> cams;
    for(int i=0;i<3;++i){
      cams.push_back(Camera(*pa("-c",i)));
    }
    capturer = new SceneMultiCamCapturer(scene, cams);
    //    Scene::enableSharedOffscreenRendering();
    scene.setDrawCamerasEnabled(false);
  }

  gui << Draw3D(Size::VGA).minSize(32,24).handle("draw")
      << (VBox().maxSize(12,100).minSize(12,1)
          << ( HBox()
               << Fps(10).handle("fps")
               << Button("add clutter").handle("add")
               )
          << ( HBox()
               << Button("stopped","running",true).out("run")
               << Button("paper ...").handle("props")
               )
          << ( HBox()
               << CheckBox("show cubes").out("showCubes")
               << CheckBox("show texture",false).out("showTexture")
               << CheckBox("show links",false).out("showLinks")
             )
          << FSlider(0,1,0.5).out("vertexMoveFactor").label("manual force")
          << FSlider(1,100,10).out("attractorStreangth").label("attractor force")
          << FSlider(0.0001,0.9999,0.9).handle("globalStiffness").label("global paper stiffness")
          << ( HBox()
               << Button("reset paper").handle("resetPaper")
               << Combo("1,5,10,25,!200,300,500").handle("maxFPS").label("max FPS")
               )
          << FSlider(0.1,20,2).handle("cm").label("collision margin")

          << ( HBox()
               << Button("memorize").handle("mem")
               << CheckBox("soften with mouse",true).handle("soften")
               << Button("test").handle("pct")
             )
          )

      << Show();

  propGUI << Prop("paper").minSize(16,1).maxSize(16,100) << Create();

  gui["pct"].registerCallback(paper_coords_test);
  gui["props"].registerCallback(utils::function((GUI&)propGUI,&GUI::switchVisibility));
  gui["resetPaper"].registerCallback(reset_paper);
  gui["globalStiffness"].registerCallback(change_global_stiffness);

  scene.PhysicsWorld::addObject(&ground);
  scene.Scene::addObject(&groundVis);

  DrawHandle3D draw = gui["draw"];
  draw->install(paper->createMouseHandler(0));
  draw->install(&foldLine);
  draw->link(scene.getGLCallback(0));

  foldLine.cb = utils::function(fold_line_cb);



}
void PhysicsSim::drawBox(aabbox3df box, Color color)
{
	boxes.push_back(VBox(box, color));
}
void init(){
  bool cOut = pa("-c"), dOut = pa("-d");
  
  if(cOut){
    colorOut.init(pa("-c"));
  }
  if(dOut){
    depthOut.init(pa("-d"));
  }
  
  if(cOut || dOut){
    prevGUI << (cOut ? Image().handle("color") : Dummy())
            << (dOut ? Image().handle("depth") : Dummy())
            << Create();
  }

  gui << Draw3D().handle("draw")
      << ( VBox().minSize(10,2)
           << FSlider(-10,10,0).out("x").label("translate x")
           << FSlider(-10,10,0).out("y").label("translate y")
           << FSlider(1.5,10,0).out("z").label("translate z")
           
           << FSlider(-4,4,0).out("rx").label("rotate x")
           << FSlider(-4,4,0).out("ry").label("rotate y")
           << FSlider(-4,4,0).out("rz").label("rotate z")

           << ((cOut||dOut) ? (const GUIComponent&)Button("show","hide").label("preview").handle("preview") 
               : (const GUIComponent&)Dummy() )
           << Button("reset view").handle("resetView")
         )
      << Show();

  
  if(cOut || dOut){
    gui["preview"].registerCallback(utils::function(&prevGUI,&GUI::switchVisibility));
    if(dOut){
      ImageHandle d = prevGUI["depth"];
      d->setRangeMode(ICLWidget::rmAuto);
    }
  }
  
  Camera defaultCam(Vec(4.73553,-3.74203,8.06666,1),
                    Vec(-0.498035,0.458701,-0.735904,1),
                    Vec(0.787984,-0.116955,-0.604486,1));
  scene.addCamera( !pa("-cam").as<bool>() ? defaultCam : Camera(*pa("-cam")));
  initDepthCam = scene.getCamera(0);
  
  if(pa("-ccam")){
    scene.addCamera(*pa("-ccam"));
    Mat D=scene.getCamera(0).getCSTransformationMatrix();
    Mat C=scene.getCamera(1).getCSTransformationMatrix();
    
    relTM = new Mat( C * D.inv() );
  }

  SceneObject* ground = SceneObject::cuboid(0,0,0,200,200,3);
  ground->setColor(Primitive::quad,GeomColor(100,100,100,255));
  
  scene.addObject(ground);
  if(pa("-object")){
    scene.addObject( (obj = new SceneObject(*pa("-object"))) );
  }else{
    scene.addObject( (obj = SceneObject::cube(0,0,3, 3) ) );
  }
  obj->setColor(Primitive::quad, GeomColor(0,100,255,255));
  obj->setColor(Primitive::triangle, GeomColor(0,100,255,255));
  obj->setColor(Primitive::polygon, GeomColor(0,100,255,255));
  obj->setVisible(Primitive::line | Primitive::vertex, false);
  
  gui["draw"].link(scene.getGLCallback(0));
  gui["draw"].install(scene.getMouseHandler(0));

  scene.setDrawCamerasEnabled(false);

  scene.addCamera(scene.getCamera(0));

}