Points on the body kinect (GoToLoop)

edited June 2014 in Kinect

Hi @GoToLoop, so I decided to use this sketch ( http://forum.processing.org/two/discussion/3771/point-cloud-and-peasycam#Item_3 )you shared! I want use it in a basic kinect display, where the "points" are only the person's body with the kinect.. The sketch is rather simple.. But I want to put points where "userMap[index] != 0 " I'm trying this but getting null pointer exception. :( Any idea on how I can implement that example in this:

  import SimpleOpenNI.*;
SimpleOpenNI context;
PImage userImage;
int[] userMap;
PImage rgbImage;
color pixelColor;



void setup(){

  size(640,480);
  context=new SimpleOpenNI(this);
  context.enableRGB();
  context.enableDepth();
  context.enableUser();


  userImage=createImage(640,480,RGB);
}
void draw(){

  background(0);
  context.update();
  rgbImage=context.rgbImage();


  userMap=context.userMap();
  for(int y=0;y<context.depthHeight();y++){
    for(int x=0;x<context.depthWidth();x++){
      int index=x+y*640;
      if(userMap[index]!=0){
          pixelColor=rgbImage.pixels[index];
        userImage.pixels[index]=color(0,255,0);
      }else{
        userImage.pixels[index]=color(0);
      }


    }
  }
  userImage.updatePixels();
  image(userImage,0,0);
}

Answers

Sign In or Register to comment.