We are about to switch to a new forum software. Until then we have removed the registration on this forum.
import SimpleOpenNI.*;
SimpleOpenNI context;
void setup() { size(640,480); background(255); context = new SimpleOpenNI(this); if(context.isInit() == false) { exit(); return; } context.enableDepth();
context.enableUser(); }
void draw() { context.update();
int[] userList = context.getUsers();
for(int i=0;i<userList.length;i++) { if(context.isTrackingSkeleton(userList[i])) {
Pvector jointPos_lefthand = new PVector(); Pvector jointPos_lefthand2d = new PVector();
Pvector jointPos_leftshoulder = new PVector(); Pvector jointPos_leftshoulder2d = new PVector();
Pvector jointPos_leftelbow = new PVector(); Pvector jointPos_leftelbow2d = new PVector();
Pvector jointPos_rightshoulder = new PVector(); Pvector jointPos_rightshoulder2d = new PVector();
Pvector jointPos_rightelbow = new PVector(); Pvector jointPos_rightelbow2d = new PVector();
Pvector jointPos_righthand = new PVector(); Pvector jointPos_righthand2d = new PVector();
context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER,jointPos_leftshoulder); context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW,jointPos_leftelbow); context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_LEFT_HAND,jointPos_lefthand);
context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER,jointPos_rightshoulder); context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW,jointPos_rightelbow); context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND,jointPos_righthand);
context.convertRealWorldToProjective(jointPos_lefthand,jointPos_lefthand2d); context.convertRealWorldToProjective(jointPos_leftshoulder,jointPos_leftshoulder2d); context.convertRealWorldToProjective(jointPos_leftelbow,jointPos_leftelbow2d);
context.convertRealWorldToProjective(jointPos_rightshoulder,jointPos_rightshoulder2d); context.convertRealWorldToProjective(jointPos_rightelbow,jointPos_rightelbow2d); context.convertRealWorldToProjective(jointPos_righthand,jointPos_righthand2d);
ellipse(jointPos_lefthand2d.x,jointPos_lefthand2d.y,30,30); ellipse(jointPos_leftshoulder2d.x,jointPos_leftshoulder2d.y,30,30); ellipse(jointPos_leftelbow2d.x,jointPos_leftelbow2d.y,30,30);
ellipse(jointPos_rightshoulder2d.x,jointPos_rightshoulder2d.y,30,30); ellipse(jointPos_rightelbow2d.x,jointPos_rightelbow2d.y,30,30); ellipse(jointPos_righthand2d.x,jointPos_righthand2d.y,30,30); } } }
Answers
Case matters. It's
PVector
, notPvector
.yes, but do i need to declare PVector at the top of the code?
No but you have to change all occurrences of
Pvector
withPVector
it keeps showing errors when playing it with kinect. Can you help me figure out the errors and the missing declares? ( using kinect openNi)
Post an MCVE and the full text of any errors you're seeing, and we'll go from there.
If you want help then you need to do some preparation work.
1) if you haven't done already change all occurrences of
Pvector
withPVector
2) In Processing editor hit Ctrl+T to format the code
3) Run your sketch and make a note of the line number and error messages that occur.
4) Post your latest code in the forum, making sure you format it so that it appears with line numbers in the forum. Together with any error messages with line numbers from (3)
Be aware that Processing source code is case-sensitive.
ERROR MESSAGE: ** Cannot find anything named "userId"
Actually, i want to make the skeleton of a user draw on screen with the kinect thanks a lot
On lines 44 to 59 you're using a variable called "userId". This variable hasn't been declared anywhere before, so your sketch doesn't know what you're asking it to do. Maybe you ment to use the looping variable i in those places?
Due to I am new to processing so i dont know how
how do i declare the userId and where in my code?
The second part of TfGuy44's answer is the bit you need to consider.
In lines 49-55 try changing each
userid
toi
thank you a lot!! but the error now is:
**the method getJointPositionSkeleton(int,int,PVector) in the type simpleOpenNi is not applicable for the arguments ( int,int,int,PVector)
I think you should only be specifying ONE join that you're trying to get the position of in each call to getJointPositionSkeleton(). That is, you should be trying to get, from the i'th detected skeleton, the position of the specified join, and stored into a specified PVector:
that helped a lot thankyou!!
now that is working, how does it allow me to draw on screen using the skeletons hand?