Hi,
I've created a rhythm game for two users in Processing and Pd. I'm using the callback functions provided in the SimpleOpeni 0.27 Processing library and the problem I'm having is that sometimes User #1 will be tagged as User #2 even if there is only one user. Also, I get this message Invalid memory access of location 0x0 eip=0xffff0633 and I think it's because Kinect is only tracking User #2 the first slot in the vector might be empty. I would like to do the following:
1. Be able to change the assigned userId (tried mousePressed() and that doesn't seem to work)
2. Figure out why I'm getting this Invalid memory error
Any help would be appreciated. Thanks!
import SimpleOpenNI.*;
SimpleOpenNI kinect;
boolean autoCalib = true;
int userId;
void setup(){
fill(255, 0, 0);
kinect = new SimpleOpenNI(this);
kinect.enableDepth();//enable depth camera
kinect.enableUser(SimpleOpenNI.SKEL_PROFILE_ALL);//enable skeleton
kinect.setMirror(true);//reverse image
size (kinect.depthWidth(), kinect.depthHeight());//pixel size of images from kinect
}
void draw() {
kinect.update();//kinet update every frame
image(kinect.depthImage(), 0, 0);
IntVector userList = new IntVector();
kinect.getUsers(userList);
if (userList.size() > 0) {
for (int i = 0; i < userList.size(); i++){
userId = userList.get(i);
}
}
}
// user-tracking callbacks!
void onNewUser(int userId)
{
println("onNewUser - userId: " + userId);
println(" start pose detection");
if(autoCalib)
kinect.requestCalibrationSkeleton(userId,true);
else
kinect.startPoseDetection("Psi",userId);
}
void onLostUser(int userId)
{
println("onLostUser - userId: " + userId);
}
void onExitUser(int userId)
{
println("onExitUser - userId: " + userId);
}
void onReEnterUser(int userId)
{
println("onReEnterUser - userId: " + userId);
}
void onStartCalibration(int userId)
{
println("onStartCalibration - userId: " + userId);
}
void onEndCalibration(int userId, boolean successfull)
{
println("onEndCalibration - userId: " + userId + ", successfull: " + successfull);
if (successfull)
{
println(" User calibrated !!!");
kinect.startTrackingSkeleton(userId);
}
else
{
println(" Failed to calibrate user !!!");
println(" Start pose detection");
kinect.startPoseDetection("Psi",userId);
}
}
void onStartPose(String pose,int userId)
{
println("onStartPose - userId: " + userId + ", pose: " + pose);
println(" stop pose detection");
kinect.stopPoseDetection(userId);
kinect.requestCalibrationSkeleton(userId, true);
}
void onEndPose(String pose,int userId)
{
println("onEndPose - userId: " + userId + ", pose: " + pose);
}