hi there;
So I have a PVector that holds lots of position datas.I want to export these datas in to a txt file.I ve already tried the saveStrings() but i got error everytime.So what can i do?
Thank you
void draw() {
kinect.update();
PImage depth = kinect.depthImage();
image(depth, 0, 0);
// make a vector of ints to store the list of users
IntVector userList = new IntVector();
// write the list of detected users
// into our vector
kinect.getUsers(userList);
// if we found any users
if (userList.size() > 0) {
// get the first user
int userId = userList.get(0);
// if we’re successfully calibrated
if ( kinect.isTrackingSkeleton(userId)) {
// make a vector to store the left hand
PVector rightHand = new PVector();
PVector leftHand=new PVector();
// put the position of the left hand into that vector
float confidence = kinect.getJointPositionSkeleton(userId,
SimpleOpenNI.SKEL_RIGHT_HAND,
rightHand);
float confidence1=kinect.getJointPositionSkeleton(userId,
SimpleOpenNI.SKEL_LEFT_HAND,leftHand);
println(confidence1);
println("Right Hand");
saveStrings("hey.txt",rightHand); !!!!!!!!!!!!!
exit(); !!!!!!!!!!!!!
// convert the detected hand position
// to "projective" coordinates
// that will match the depth image
PVector convertedRightHand = new PVector();
PVector convertedLeftHand=new PVector();
kinect.convertRealWorldToProjective(rightHand, convertedRightHand);
kinect.convertRealWorldToProjective(leftHand,convertedLeftHand);
//println("Converted");
println(convertedRightHand);
// and display it
fill(255,0,0);
if(confidence>0.5){
float ellipseSize1=map(convertedLeftHand.z,700,5000,50,1);
ellipse(convertedLeftHand.x,convertedLeftHand.y,
ellipseSize1,ellipseSize1);}
//ellipse(convertedRightHand.x, convertedRightHand.y, 10, 10);
if (confidence>0.5){
float ellipseSize = map(convertedRightHand.z, 700, 5000, 50, 1);
ellipse(convertedRightHand.x, convertedRightHand.y,
ellipseSize, ellipseSize);}
}
}
}
righthand 's content is :[-124.671906, -1083.6913, 2173.4915] etc.
And the error is:__the method saveString(String,String[]) in the type PApplet is not applicable for the arguments (String,PVector)_
_
Thank for your responses!!
Have you really looked at my example above? Especially within keyTyped()'s for loop block?
Where a List<PVector> is converted into int[]. And finally into String[]? :-w
And if you really need float, use the comment out part instead.
I'm puzzled by your code above! 8-| You're using append() on a non-Array variable -> rightHand. X_X
Moreover, I don't think Array is the right structure for dynamic-sized lists! /:)
That's only appropriate when we know in advance how many units we're gonna use!
Take notice I've chosen List in my own example. More specifically, an ArrayList<PVector> structure. ;;)
Since saveStrings() demands a String[], only at that point we'd need to temporarily convert our main structure to that 1!
For only this row I want to change the PVector to [0,0,0] when confidence1 < 0.5.
When a PVector is instantiated, its default values are [0, 0, 0] already! (~~)
And to change the values of an existing PVector object, use its set() method!
Answers
what error? how are you trying saveStrings()? what kind of data are you trying to export. give us some code! :)
seriously though, saveStrings() should be the right way, but without some of your code everything is just a shot in the dark to try and troubleshoot.
ak
Got an old example here from the old forum:
So code thath I am using is;
righthand 's content is :[-124.671906, -1083.6913, 2173.4915] etc. And the error is:__the method saveString(String,String[]) in the type PApplet is not applicable for the arguments (String,PVector)_ _ Thank for your responses!!
Have you really looked at my example above? Especially within keyTyped()'s for loop block?
Where a List<PVector> is converted into int[]. And finally into String[]? :-w
And if you really need float, use the comment out part instead.
Yes you are right!!Sorry.I worked it out it is fine now.But I have another question?I would be very pleased if you answer!!
For only this row I want to change the PVector to [0,0,0] when confidence1<0.5 So how can I do that?Thank you !!
I'm puzzled by your code above! 8-| You're using append() on a non-Array variable -> rightHand. X_X
Moreover, I don't think Array is the right structure for dynamic-sized lists! /:)
That's only appropriate when we know in advance how many units we're gonna use!
Take notice I've chosen List in my own example. More specifically, an ArrayList<PVector> structure. ;;)
Since saveStrings() demands a String[], only at that point we'd need to temporarily convert our main structure to that 1!
When a PVector is instantiated, its default values are [0, 0, 0] already! (~~)
And to change the values of an existing PVector object, use its set() method!