Silhouette Kinect V2 + Removing Background

Hello There,

And thank you for your amazing work. I’m a beginner in processing and I am trying to remove the background from the information captured through a kinectv2. I’ve made a Threshold selection of the depth information and would like to convert the pixels displayed in the image I attach that are now shown in black as an alpha channel. My idea is to end up using the body’s silhouette to draw your movement on the screen with a delayed effect. Liked in the following example: https://www.youtube.com/watch?v=YBKkVpRxUfs
I would really appreciate your help.

Here is the coding I have now:

import org.openkinect.freenect.*;
import org.openkinect.freenect2.*;
import org.openkinect.processing.*;
import org.openkinect.tests.*;

Kinect2 kinect2;

float minThresh = 480;
float maxThresh = 830;

PImage img;

void setup() {
  //size(1280, 720);
  fullScreen(FX2D);
  kinect2 = new Kinect2(this);
  kinect2.initDepth();
  kinect2.initDevice();
  img = createImage(kinect2.depthWidth, kinect2.depthHeight, RGB);
}

void draw() {
  background(255, 0, 0);

  img.loadPixels();
  int[] depth = kinect2.getRawDepth();


  for (int x = 0; x < kinect2.depthWidth; x++) {
    for (int y = 0; y < kinect2.depthHeight; y++) {
      int offset = x + y * kinect2.depthWidth;
      int d = depth[offset];
      if (d > minThresh && d < maxThresh) {
        img.pixels[offset] = color(255);
      } else {
        img.pixels[offset] = color(0, 0, 0, 0);
      }
    }
  }

  noStroke();
  img.updatePixels();
  image(img, 0, 0);
}
1 Like

@mrtnmur – were you able to resolve this issue?

You might be interested in these past discussions of implementing a sketch similar to Recollections: