We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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:
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);
kinect.enableBodyTrackImg(true);
kinect.enableColorImg(true);
kinect.enableDepthMaskImg(true);
kinect.init();
}
void draw() {
background(255);
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();
updatePixels();
//image(cpy, 0, 0);
}
Answers
Have you solved this? I'm trying to do something similar.
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?