Combine RGB data with Body Track to only show RGB of Bodies (KINECTV2/KINECTPV2 LIBRARY)

edited March 2017 in Kinect

I am using Thomas Lengeling's KinectPV2 library to try to get processing to save/display only the RGB data of the bodies it detects.

Right now when it runs it displays the color image not filtered through body data, like this:

sketch_170326b 26-Mar-17 21_21_27

Regardless of whether or not a body is tracking in the space

When I want the finished projected product to look more like this:


Here's vaguely what I've tried (by referencing the pixels in the body track, based on Thomas Lengeling's examples for depth to color & body track users:

//source code from Thomas Lengeling

import KinectPV2.*;

KinectPV2 kinect;

PImage body;

PImage bodyRGB;

int loc;

void setup() {
  size(512, 424, P3D);

  //bodyRGB = createImage(512, 424, PImage.RGB); //create empty image to hold color body pixels

  kinect = new KinectPV2(this);



void draw() { 

  body = kinect.getBodyTrackImage(); //put body data in variable

  bodyRGB = kinect.getColorImage(); //load rgb data into PImage

  //println(bodyRGB.width); 1920x1080 //println(bodyRGB.height);

  PImage cpy = bodyRGB.get();

  cpy.resize(width, height);

  //int [] colorRaw = kinect.getRawColor(); //get the raw data from depth and color

  //image(body,0,0); //display body

  loadPixels(); //load sketch pixels
  cpy.loadPixels();//load pixels to store rgb
  body.loadPixels(); //load body image pixels

  //create an x, y nested for loop for pixel location
  for (int x = 0; x < body.width; x++ ) { 
    for (int y = 0; y < body.height; y++ ) { 
      //pixel location 
      loc = x + y * body.width; 
      if (color(body.pixels[loc]) != 255) {
        color temp = color(cpy.pixels[loc]); 
        pixels[loc] = temp;

  //cpy.updatePixels(); //body.updatePixels(); 


  //image(cpy, 0, 0);


  • Have you solved this? I'm trying to do something similar.

  • edited April 2017

    No, I couldn't get it to work, sorry. I ended up going another route. It tracks color to depth fairly well, there might be a work around there?

Sign In or Register to comment.