SimpleOpenNI setMirror() not working

edited May 2014 in Kinect

setMirror() seems to have no effect either way. What am I missing? I can't get a mirror image regardless of true or false setting. Please help!!

import SimpleOpenNI.*;

SimpleOpenNI kinect; int userId;

void setup() { size(640, 480); kinect = new SimpleOpenNI(this); kinect.enableDepth(); kinect.enableUser(); kinect.setMirror(true);

stroke(255, 0, 0); strokeWeight(3); smooth(); } void draw() { background(0); kinect.update(); kinect.setMirror(false);

IntVector userList = new IntVector(); kinect.getUsers(userList); if (userList.size() > 0) { userId = userList.get(0); if ( kinect.isTrackingSkeleton(userId)) { drawSkeleton(); } } }

// SimpleOpenNI events --------------------------------------------

void onNewUser(SimpleOpenNI kinect, int userId) { // did originally say curContext from user library kinect_User_02 println("onNewUser - userId: " + userId); println("\tstart tracking skeleton"); kinect.startTrackingSkeleton(userId); } void onLostUser(SimpleOpenNI kinect, int userId) { println("onLostUser - userId: " + userId); }

void drawSkeleton() {

kinect.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

kinect.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER); kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW); kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

kinect.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER); kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW); kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO); kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

kinect.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP); kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE); kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

kinect.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP); kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE); kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT); }

Answers

  • Sorry about the formatting. I missed the markup feature

  • edited May 2014

    Click on edit and select your code and hit ctrl+k to format your code.

    Questions

    1. What version of simepleopenNI you are using ?
    2. If it is 0.27 then it should work else it is possible that in newer version it is not avaiable. Here is one refrence.
  • edited May 2014

    Just check if this is working. Also why did you setMirror property in draw() ? You just have to do it once, in setup only. So if you want to change it then change it in the setup.

    import SimpleOpenNI.*;
    
    SimpleOpenNI kinect; 
    int userId;
    
    void setup() { 
      size(640, 480); 
      kinect = new SimpleOpenNI(this); 
      kinect.enableDepth(); 
      kinect.enableRGB(); 
      kinect.enableUser(); 
      kinect.setMirror(true);
    } 
    void draw() { 
      background(0); 
      kinect.update(); 
      image(kinect.depthImage(), 0, 0);
      image(kinect.rgbImage(), 0, 0);
      IntVector userList = new IntVector(); 
      kinect.getUsers(userList); 
      if (userList.size() > 0) { 
        userId = userList.get(0); 
        if ( kinect.isTrackingSkeleton(userId)) { 
          drawSkeleton();
        }
      }
    }
    
    // SimpleOpenNI events --------------------------------------------
    
    void onNewUser(SimpleOpenNI kinect, int userId) { 
      // did originally say curContext from user library kinect_User_02 
      println("onNewUser - userId: " + userId); 
      println("\tstart tracking skeleton"); 
      kinect.startTrackingSkeleton(userId);
    } 
    
    void onLostUser(SimpleOpenNI kinect, int userId) { 
      println("onLostUser - userId: " + userId);
    }
    
    void drawSkeleton() {
    
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);
    
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER); 
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW); 
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);
    
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER); 
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW); 
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);
    
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO); 
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);
    
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP); 
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE); 
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);
    
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP); 
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE); 
      kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);
    }
    
Sign In or Register to comment.