Export to GitHub

simple-openni - issue #87

SimpleOpenNi 1.96 lib error


Posted on Nov 5, 2013 by Helpful Dog

What steps will reproduce the problem? 1. Running code that Kinect Silhouette (libs: SimpleOpenNI)

What is the expected output? What do you see instead? Kinect Silhouette (libs: SimpleOpenNI)

----------code below------------------ import SimpleOpenNI.*; SimpleOpenNI context; PImage cam;

void setup() {

size(640, 480);

context = new SimpleOpenNI(this);

context.enableUser(); if(context.isInit() == false) { println("Can't init SimpleOpenNI, maybe the camera is not connected!"); exit(); return;
} else {

context.setMirror(true);

} }

void draw() {

context.update();

// cam = context.sceneImage().get(); cam = context.userImage().get();

image(cam, 0, 0);

}

It is example of Kinect Silhouette according to this link

(http://www.creativeapplications.net/processing/kinect-physics-tutorial-for-processing/)

What version of the product are you using? On what operating system? Windows 7 Processing 2.0 SimpleOpenNi 1.96 Kinect SDK 1.7

I followed introduction of official simple-openni homepage.

Please provide any additional information below.

I modify above example because enablescene and sceneImage was changed to enableUser and userImage.

But nevertheless modify code not run.

It said "NullPointerException" at imege(context.userImage(), 0, 0);

Is that example had originally error?

Comment #1

Posted on Nov 11, 2013 by Happy Bear

I got the same error. It said "NullPointerException" at imege(context.userImage(), 0, 0); can anyone let me know how to fix this?

Comment #2

Posted on Nov 12, 2013 by Helpful Dog

I fixed the problem my self..

void draw() { background(0); context.update();

// if we have detected any users if (context.getNumberOfUsers() > 0) {

// find out which pixels have users in them
userMap = context.userMap(); 

// populate the pixels array
// from the sketch's current contents
loadPixels(); 
for (int i = 0; i < userMap.length; i++) { 
  // if the current pixel is on a user
  if (userMap[i] != 0) {
    // make it green
    pixels[i] = color(0, 255, 0); 
  }
}
// display the changed pixel array
updatePixels(); 

} } Point is using userMap displayed by pixel..

Comment #3

Posted on Dec 9, 2013 by Happy Hippo

I tried the above code, but I get the error "Cannot find anything named 'userMap'." How can I fix this?

My code so far is:

import SimpleOpenNI.*; SimpleOpenNI context;

PImage cam;

void setup() { size(640, 480);

context = new SimpleOpenNI(this);

// mirror the image to be more intuitive
context.setMirror(true);

}

void draw() { background(0); context.update();

if(context.getNumberOfUsers() > 0) {

userMap = context.userMap();

loadPixels();
for(int i = o; i < userMap.length; i++) {

  if (userMap[i] !=0) {
    pixels[i] =color(0, 255, 0);
  }
}
updatePixels();

} }

Comment #4

Posted on Dec 9, 2013 by Helpful Dog

@annieckb..

You have to write context.enableDepth();

and context.enableUser();

in the void setup()

Comment #5

Posted on Dec 9, 2013 by Helpful Dog

Here is my full code. It can be useful for all.

import processing.opengl.; import SimpleOpenNI.; SimpleOpenNI context; PImage userImage; int userID; int[] userMap;

PImage rgbImage; void setup() { size(640, 480, OPENGL); context = new SimpleOpenNI(this); context.enableDepth(); context.enableUser(); } void draw() { background(0); context.update(); if (context.getNumberOfUsers() > 0) { userMap = context.userMap(); loadPixels(); for (int i = 0; i < userMap.length; i++) { if (userMap[i] != 0) { pixels[i] = color(0, 255, random(100, 200)); } } updatePixels(); } } void onNewUser(int uID) { userID = uID; println("tracking"); }

Comment #6

Posted on Dec 9, 2013 by Happy Hippo

@kdhyun1...

When I use your code I get a gray screen and nothing happens... When I insert the enableDepth en de enableUser I still get the error: cannot find anything named Usermap.

my code sofar:

import SimpleOpenNI.*; SimpleOpenNI context;

PImage cam;

void setup() { size(640, 480);

context = new SimpleOpenNI(this);

// mirror the image to be more intuitive
context.setMirror(true);

context.enableDepth(); context.enableUser();

}

void draw() { background(0); context.update();

if(context.getNumberOfUsers() > 0) {

userMap = context.userMap();

loadPixels();
for(int i = o; i < userMap.length; i++) {

  if (userMap[i] !=0) {
    pixels[i] =color(0, 255, 0);
  }
}
updatePixels();

} }

What on earth am I doing wrong?!

Comment #7

Posted on Dec 12, 2013 by Swift Horse

Comment deleted

Comment #8

Posted on Dec 12, 2013 by Swift Horse

I was looking for the same answers as you were, luckily I was able to find the minor flaws in your code:

import SimpleOpenNI.*; SimpleOpenNI context;

PImage cam; int[] userMap; // YOU FORGOT THIS ONE

void setup() { size(640, 480);

context = new SimpleOpenNI(this);

// mirror the image to be more intuitive
context.setMirror(true);

context.enableDepth(); context.enableUser();

}

void draw() { background(0); context.update();

if(context.getNumberOfUsers() > 0) {

userMap = context.userMap();

loadPixels();
for(int i = 0; i < userMap.length; i++) {  // YOU HAD AN o instead of 0

  if (userMap[i] !=0) {
    pixels[i] =color(0, 255, 0);
  }
}
updatePixels();

} }

Comment #9

Posted on Dec 13, 2013 by Happy Hippo

Thanks A lot, it works now!

What I am trying to do is put lines of text where the silhouette is now, like http://www.youtube.com/watch?v=h5a8UZCgs14&feature=c4-overview-vl&list=PL-UtJb4Mt-OLCuxLfvv__jGOboQ-35ZRw

how can I do this?

Comment #10

Posted on Apr 6, 2014 by Happy Ox

I had the same problem but while trying your solution it didn't work. I realized my problem was with the context.enableRGB(640,480,30).simple removing the arguments solved the problem i.e just use context.enableRGB() without arguments.

Comment #11

Posted on Jul 20, 2014 by Happy Dog

I am new to kinect programming with processing what is the significance of onNewUser() function?? is this functiocalled out implicity ?? who calls it?????? Please tell everything about onNewUser()

Status: New

Labels:
Type-Defect Priority-Medium