Hello all
I’ve been programming interactive apps using a Kinect v2 model 1520 using Processing 3.5.3. This app will be for a top-down projection that uses a persons blob to reveal an image below another. In effect, the blob will temporarily mask out the Top image to reveal the Base image. The current app uses a Kinect depth image as a PImage, which is used as an image mask. The below code works fine for my purpose but has one issue:
The Kinect depth image is 512x424, and to use this as a mask, the Top and Base images also need to be 512x424, or Processing gives an error. This is too low a resolution to be projected at 3m square.
Is there any way to resize the Kinect depth map to be 1280x720 or 1920x1080, so that the Top and Base images can be this resolution?
I have tried to resize the depth PImage using PImage.resize with no luck. I’ve also tried to put the depth data into an int array and use this as a mask but no luck with this either. The blob hasn’t got to be amazing resolution, as its being blurred anyway. But the Top and Base images need to be high resolution.
I would really appreciate some help in making the overall sketch run at this higher resolution. Thanks!
Heres the working code:
import org.openkinect.freenect.*;
import org.openkinect.freenect2.*;
import org.openkinect.processing.*;
import org.openkinect.tests.*;
Kinect2 kinect2;
PImage base;
PImage top;
PImage depthImg;
int minDepth = 100;
int maxDepth = 1500;
void setup() {
fullScreen(P2D);
kinect2 = new Kinect2(this);
kinect2.initDepth();
kinect2.initDevice();
base = loadImage("base.jpg");
top = loadImage("top.jpg");
depthImg = new PImage(kinect2.depthWidth, kinect2.depthHeight);
}
void draw() {
image(base, 0, 0, width, height);
int[] rawDepth = kinect2.getRawDepth();
for (int i=0; i < rawDepth.length; i++) {
if (rawDepth[i] >= minDepth && rawDepth[i] <= maxDepth) {
depthImg.pixels[i] = color(255);
} else {
depthImg.pixels[i] = color(0);
}
}
depthImg.updatePixels();
depthImg.filter(BLUR, 5);
image(top, 0, 0, width, height);
top.mask(depthImg);
}