How to mirror kinect depth image with dLib-freenect ?

edited November 2016 in Kinect

Hello,

I'm working with dLib-freenect (https://github.com/diwi/dLibs) to use kinect v1 with PC and Processing 3. The mirror method used with openKinect doesn't work : kinect_.enableMirror(true); Same problem with kinect_.set Mirror(true); There is no mirror method with dLib-freenect.

So I tried something like that :

int[] rawDepth = kinect_depth_.getRawDepth();
  for(int i =0; i < kinectFrame_size_x; i++) {
    for(int j =0; j < kinectFrame_size_y; j++) {
    //int offset = i+j*kinectFrame_size_x;
//I try to flip the depth image
    int offset = (kinectFrame_size_x-i-1)+j*kinectFrame_size_x;
    int d = rawDepth[offset];
     ...  } }

but the image is not flipped. Any idea ?

Thanks a lot !

Answers

  • I tried using : int offset = i+j*kinectFrame_size_x; or int offset = kinectFrame_size_x-i-1+j*kinectFrame_size_x; as I saw this post : https://forum.processing.org/one/topic/un-mirror-an-image.html but nothing change, kinect image is not flipped. Can you help me ?

  • I solved the problem :

    int[] rawDepth = kinect_depth_.getRawDepth();
      for (int i =0; i < kinectFrame_size_x; i++) {
        for (int j =0; j < kinectFrame_size_y; j++) {
          int offset = i+j*kinectFrame_size_x;
    
          int d = rawDepth[offset];
          int pix = kinectFrame_size_x-i-1+j*kinectFrame_size_x;
          if (d >= minDepth && d <= maxDepth) {
    
            img.pixels[pix] = color(255);
          } else {
            img.pixels[pix] = color(0);
          }
    
          if (d >= minDepth2 && d <= maxDepth2) {
            img2.pixels[pix] = color(255, 75);
          } else { 
            img2.pixels[pix] = bg.pixels[pix];
          }
        }
      }
      img.updatePixels(); 
      img2.updatePixels();
    
  • @chambefort Thxs for sharing your answer!

    Kf

Sign In or Register to comment.