Esempio n. 1
0
void run(){

  listener->waitForNewFrame(*frames);
  libfreenect2::Frame *rgb = (*frames)[libfreenect2::Frame::Color];
  libfreenect2::Frame *ir = (*frames)[libfreenect2::Frame::Ir];
  libfreenect2::Frame *depth = (*frames)[libfreenect2::Frame::Depth];
  
  
  static Img8u colorImage(Size(rgb->width,rgb->height),3);

  if(depth){
    Img32f depthImage(Size(depth->width,depth->height),formatMatrix,
                      std::vector<float*>(1, (float*)depth->data));
    gui["hdepth"] = &depthImage;
  }else{
    throw ICLException("error detected in libfreenect2.so: please ensure to deactivate"
                       " visualization in ....h by setting debug_on to false");
  }
  
  Img32f irImage(Size(ir->width,ir->height),formatMatrix, 
                 std::vector<float*>(1,(float*)ir->data));
  
  interleavedToPlanar(rgb->data, &colorImage);
  colorImage.swapChannels(0,2);
  
  //gui["hdepth"] = &depthImage;
  gui["hcolor"] = &colorImage;
  gui["hir"] = &irImage;
  
  listener->release(*frames);
}