Open GoogleCodeExporter opened 8 years ago
I got the same error.
It said "NullPointerException" at imege(context.userImage(), 0, 0);
can anyone let me know how to fix this?
Original comment by 01.ahn.e...@gmail.com
on 11 Nov 2013 at 7:28
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..
Original comment by kdhyun1...@gmail.com
on 12 Nov 2013 at 12:20
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();
}
}
Original comment by annieckb...@hotmail.com
on 9 Dec 2013 at 8:10
@annieckb..
You have to write context.enableDepth();
and context.enableUser();
in the void setup()
Original comment by kdhyun1...@gmail.com
on 9 Dec 2013 at 9:57
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");
}
Original comment by kdhyun1...@gmail.com
on 9 Dec 2013 at 9:59
@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?!
Original comment by annieckb...@hotmail.com
on 9 Dec 2013 at 10:45
[deleted comment]
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();
}
}
Original comment by rikvan...@live.nl
on 12 Dec 2013 at 1:15
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-UtJb4M
t-OLCuxLfvv__jGOboQ-35ZRw
how can I do this?
Original comment by annieckb...@hotmail.com
on 13 Dec 2013 at 1:42
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.
Original comment by aboum...@gmail.com
on 6 Apr 2014 at 8:43
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()
Original comment by dheerajd...@gmail.com
on 20 Jul 2014 at 10:04
Original issue reported on code.google.com by
kdhyun1...@gmail.com
on 5 Nov 2013 at 12:45