jdeboi / simple-openni

Automatically exported from code.google.com/p/simple-openni
0 stars 0 forks source link

SimpleOpenNi 1.96 lib error #87

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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-proc
essing/)

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?

Original issue reported on code.google.com by kdhyun1...@gmail.com on 5 Nov 2013 at 12:45

GoogleCodeExporter commented 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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
@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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
@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

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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