SimpleOpenNi

edited May 2014 in Kinect

Hi everyone. I'm sorry for my english but i'm learning for it. I'm using the library SimpleOpenNi and i need to see the difference between two nearly frames. I need to delete background pointing out the moving object. Some one have an idea? I used this code but doesn't work. Ty.

import SimpleOpenNI.*;
SimpleOpenNI kinect;
PImage myImage = createImage(640,480,RGB);

void setup()
{
 size(1320, 480);
 kinect = new SimpleOpenNI(this);
 kinect.enableDepth();
}
void draw()
{
 kinect.update();
 PImage depthImage = kinect.depthImage();
  int[] depthValues = kinect.depthMap();

myImage.loadPixels();
  for (int i = 0; i < 640*480; i++) {
    if(myImage.pixels[i]!= depthValues[i])
    {
          myImage.pixels[i] = depthValues[i];

    }

  }
  myImage.updatePixels();
 image(myImage, 0, 0);
 image(depthImage,640,0);
}

Answers

  • Try 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);
    }
    
Sign In or Register to comment.