none
Documentation for Microsoft.Kinect.Tools API

    General discussion

  • I'm trying to use the KStudio classes in the Microsoft.Kinect.Tools.dll to record and play back data streams from the Kinect. I found some (very) limited documentation here: http://msdn.microsoft.com/en-us/library/microsoft.kinect.tools.aspx

    However, there is no real documentation that I've been able to find about how to use the tools provided there. I see there is a KStudioClient class with recording methods available but I haven't been able to figure out how to instantiate the KStudioClient class without getting errors. I've tried:

    KStudioClient kStudioClient = KStudio.CreateClient();

    But this throws an exception: "Operation is not valid due to the current state of the object" (object here referring to kStudioClient or KStudio, I'm not sure).

    Has anyone had any luck using the KStudio classes or is there some documentation somewhere I may have missed?

    Thanks!

    Tuesday, September 16, 2014 6:15 PM

All replies

  • As a reminder this is a developer library/api only and the binaries are not to be distributed. It is only for internal applications where the SDK will be used only.

    The issue occurs because it is missing the binary files from the KStudio folder. If you copy the entire contents of the KinectStudio folder with this post build command should fix the error:

    xcopy "$(KINECTSDK20_DIR)Tools\KinectStudio\KStudioService.dll" "$(TargetDir)" /S /R /Y /I

    some boiler plate code looks like this:

    public static void RecordClip(string filePath, TimeSpan duration)
    {
        using (KStudioClient client = KStudio.CreateClient())
        {
    client.ConnectToService();
    
    KStudioEventStreamSelectorCollection streamCollection = new KStudioEventStreamSelectorCollection();
                streamCollection.Add(KStudioEventStreamDataTypeIds.Ir);
                streamCollection.Add(KStudioEventStreamDataTypeIds.Depth);
                streamCollection.Add(KStudioEventStreamDataTypeIds.Body);
                streamCollection.Add(KStudioEventStreamDataTypeIds.BodyIndex);
    
           using (KStudioRecording recording = client.CreateRecording(filePath, streamCollection))
           {
               recording.StartTimed(duration);
               while (recording.State == KStudioRecordingState.Recording)
               {
                   Thread.Sleep(500);
               }
    
               if (recording.State == KStudioRecordingState.Error)
               {
                   throw new InvalidOperationException(“Error: Recording failed!”);
               }
           }
           
    client.DisconnectFromService();
        }
    }
    
    public static void PlaybackClip(string filePath, uint loopCount)
    {
        using (KStudioClient client = KStudio.CreateClient())
        {
           client.ConnectToService();
           
           using (KStudioPlayback playback = client.CreatePlayback(filePath))
           {
               playback.LoopCount = loopCount;
               playback.Start();
    
               while (playback.State == KStudioPlaybackState.Playing)
               {
                   Thread.Sleep(500);
               }
    
               if (playback.State == KStudioPlaybackState.Error)
               {
                   throw new InvalidOperationException(“Error: Playback failed!”);
               }
           }
    
           client.DisconnectFromService();
        }
    }

    Carmine Sirignano - MSFT




    Tuesday, September 16, 2014 9:46 PM
    Owner
  • Sourcing multiple recordings files simultaneously:

    What are my options regarding working with multiple KStudioClient/KStudioPlayback simultaneously? Could this be done and used to visualize (say via Unity3D) information stored on multiple files?

    Thanks !


    Guy

    Wednesday, December 10, 2014 1:59 PM
  • Hi Carmine,

    I used this code, but my recorded video has an extremely slow fps rate. The video is 10sec, and I think it contains just 5-6 different frames.

    When I use the Kinect Studio, I don't have any problem.

    Is it my computer's fail, or I should write I faster code(is it possible)?

    Thanks in advance!

    Tuesday, March 17, 2015 2:27 PM
  • hi,Carmine

    I am  so confused cause I have been learning Kinect for a limited period. Could you please tell me  how to  call the functions in the event handlers ?  What parameters are transmitted to the functions?

    And  how many variables should I declare here?  Thank you very much...

      private void record_Click(object sender, RoutedEventArgs e)
            {
                   //What should I do here?
            }
    
      private void replay_Click(object sender, RoutedEventArgs e)
            {
              //What should I do here?
    
            }



    • Edited by oniya Wednesday, March 25, 2015 1:49 PM
    Wednesday, March 25, 2015 1:43 PM
  • Performance is going to be a factor of the system. The Kinect Studio api's would be no different then running the tool. You need to ensure your hardware(primarily HD and RAM and CPU) can handle the overhead.

    Carmine Sirignano - MSFT

    Wednesday, March 25, 2015 6:23 PM
    Owner
  • The code provided above is what you need. You will want to create separate threads that the start and stop since you need to keep the thread alive until you are done capturing(hence the sleep timeout period). You may want to work with someone who is .Net developer to assist since the SDK does require that you have the basic knowledge of programming in .Net to use it.

    There is a lot to read up on, but this might help with the basics of the programming language: https://msdn.microsoft.com/en-us/library/67ef8sbd.aspx?f=255&MSPPError=-2147217396


    Carmine Sirignano - MSFT

    Wednesday, March 25, 2015 6:27 PM
    Owner
  • Hi,

    Thank you so much for your help Carmine. Is it possible to have a complete sample to show us how to write a programm to record Kinect Data ? Is is possible to write a such programm in C++ or is is only possible in c# ?

    Thank you so much

    Wednesday, April 01, 2015 12:15 PM
  • Carmine,

    thank you so much for your help.

    I found out that when replaying videos, as soon as the sensor or the Kinect-enabled software loads the recorded file the body frame information is dropped (even if it is present in the original file). The system takes a while to start recalculating the body joint positions and this usually only happens if the tracked body is moving. In other words, I save the videos with my own custom applications after bodies and faces are tracked, then the subjects do not move during the recording. Then when I replay these videos, the system has trouble detecting the skeletons because nothing is moving. But the body frame data are already in the video file. This happens every time you use the client.ConnectToService, because when replaying the video, without being connected to the service, the skeleton tracking information is there.

    Any ideas?

    Thanks a lot




    Wednesday, January 27, 2016 9:46 PM
  • Hi,

    I'm using KStudio to record, and calling it from my game. When i'm calling Client.ConnectToService from the main game thread the frame rate drops from 60 and the game runs at about 40.When calling ConnectToService from another thread the FPS remains at 60.

    It seems like I'm happy and my problem is solved :-). but the thing that annoys me is that i cannot monitor the recording file size and duration when not running on the main thread, for some mysterious reason the Recording properties does not update (only the state property updates). This problem didn't occur when i connected the client from the main thread.

    BTY,

    it doesn't matter if i start the recording itself from the main thread or from the thread that connected the client.

    Thanks,

    Itay.

    Monday, February 08, 2016 1:44 PM