How can I take a specific segment of the rawDepthData in order to make a live mask?

Hi there. I am trying to do live subtraction while filming someone laying on the floor. The Kinect is facing top down 2.5-3.5 metres high and I want to create a mask of the person moving. I am sending two images to Isadora for masking, but would be great to know if I can do the mask in processing and send one masked image with Spout to Resolume Arena for the final compositing. Trying to make this as simple as possible, but have limited experience in code.

I have Windows 8.1 Processing 3.0 with Lengeling's library Resolume Arena 5 Kinect v 2.0

Below is the code I'm trying. I don't know how to scan a certain bit of the rawDepthData I tried an array, but this is not working.

import spout.*; import KinectPV2.*;

PImage img; PGraphics canvas; PGraphics canvas2; KinectPV2 kinect; Spout spout; Spout spout2; int thresholdH = 1200; // max distance (in mm) int thresholdL = 0; // min distance (in mm)

boolean foundUsers = false;

void setup() { size(640, 360, P3D); textureMode(NORMAL); kinect = new KinectPV2(this); kinect.enableDepthImg(true); kinect.enableBodyTrackImg(true); kinect.enableColorImg(true); kinect.init();

canvas = createGraphics(1280, 720, P3D); canvas2 = createGraphics(1280, 720, P3D); img = loadImage("SpoutLogoMarble3.bmp"); spout = new Spout(this); spout2 = new Spout(this); spout.createSender("rgb image"); spout2.createSender("mask");

}

void draw() {

background(0, 90, 100); noStroke(); canvas.beginDraw(); canvas.image(kinect.getColorImage(), 0, 0, 1920, 1080); canvas.endDraw();

      spout.sendTexture(canvas);

int [] rawData = kinect.getRawDepthData(); //read kinect depth canvas2.beginDraw(); canvas2.loadPixels(); // draw the depth image in white between high and low limits for (int x = 0; x < kinect.depthWidth; x++) { for (int y = 0; y < kinect.depthHeight; y++) { int offset = x + y * kinect.depthWidth; int rawDepth = rawData[offset]; int pix = x + y*img.width; if (rawDepth > thresholdL && rawDepth < thresholdH) { canvas2.pixels[pix] = color(255, 255, 255, 255); //draw white inside limits } else { canvas2.pixels[pix] = color(0, 0, 0, 0); //draw black outside limits } } } canvas2.updatePixels(); canvas2.endDraw(); spout2.sendTexture(canvas2);

}

Answers

  • Please format your code. Edit post, select code and hit ctrl+o. Ensure there is an empty line before and after your code.

    Kf

  • What is the relationship btw the two images?

    Kf

Sign In or Register to comment.