Save 3D joint position in a txt file frame by frame RRS feed

  • Question

  • Hi, guys,

    I am a new programmer, now I am trying to output the 3D joint position to a txt file frame by frame.

    I have got the 3D position of all the joints, I try to write a code to save it in txt, but the next frame joint position will

    cover the position this frame, finally I only get the txt file store the position in last frame. How can I output them

    frame by frame ?

    Can anyone give me a help ? I use C#.


    Thank you very much !




    • Edited by SongKinect Friday, December 16, 2011 6:41 PM
    Friday, December 16, 2011 6:05 PM

All replies

  • Hi Song,

    I think you're trapped by a programming problem. I have saved 3D position of all the joints and the program works ok.

    So, I'm wondering that you have to check your code.

    Next is my code fragment, you can reference that for your use.

    Forgive my pool English...

    m_WriteToTxt = new StreamWriter("Data\\score.txt", true);
    string Data = "";
                            m_WriteToTxt.Write(DateTime.Now.ToString("HH:mm:ss:fff") + '\t');
    for (int i = 0; i < NumOfJoint; i++){
                                x = (int)X[i];
                                y = (int)Y[i];
                                z = (int)Z[i];
                                Data += x.ToString() + '\t' + y.ToString() + '\t' + z.ToString() + '\t';

    • Proposed as answer by ykbharat Sunday, May 6, 2012 12:44 PM
    Saturday, December 17, 2011 3:18 AM
  • every time you try to save your text file representation of joint data your always creating a new file so thats why your only left with the most recent data you saved. you should try using the FileStream to create files as your have better control over the file your creating for example your be able to always keep the file open so that new data written in to it will append to the end of the file or you be able to open a previously saved file in append mode incase you wanted to save more joint data at another date and plus your be able to set read and write share accsess when using the FileStream class.
    Saturday, December 17, 2011 3:28 AM