none
Recording and Replaying with KStudioClient RRS feed

  • Question

  • I am using the color basics samples and trying to record some clips. I've tried,but throws a exception,I don’t know how to do with this:

    "System. ArgumentException" type of exception in  Microsoft.Kinect.Tools.dll, but not in the user code for processing

    private delegate void NoArgDelegate();
    
    private delegate void OneArgDelegate(string arg);
    
    private bool isRecording;
    
    private bool isPlaying;
    
    private TimeSpan duration = TimeSpan.Zero;
    
    private uint loopCount = 10;
    
    KStudioClient client = KStudio.CreateClient();
    
     ///
     /// Code to initialize MainWindow etc
     /// 
     private void record_Click(object sender, RoutedEventArgs e)
            {
                this.isRecording = true;
                this.UpdateButtonState();
    
                // Start running the recording asynchronously
                OneArgDelegate recording = new OneArgDelegate(this.RecordClip);
                recording.BeginInvoke(@"C:\temp\kinectRecording0.xef", null, null);
            }
    
            private void UpdateButtonState()
            {
               // ??what shoud I Do here?
            }
    
            private void replay_Click(object sender, RoutedEventArgs e)
            {
                this.isPlaying = true;
                this.UpdateButtonState();
                // Start running the playback asynchronously
                OneArgDelegate playback = new OneArgDelegate(this.PlaybackClip);
                playback.BeginInvoke(@"C:\temp\kinectRecording0.xef", null, null);
            }
    
            /// <summary>
            /// Records a new .xef file
            /// </summary>
            private void RecordClip(string filePath)
            {
                // Specify which streams should be recorded
                KStudioEventStreamSelectorCollection streamCollection = new KStudioEventStreamSelectorCollection();
                streamCollection.Add(KStudioEventStreamDataTypeIds.Ir);
                streamCollection.Add(KStudioEventStreamDataTypeIds.Depth);
                streamCollection.Add(KStudioEventStreamDataTypeIds.Body);
                streamCollection.Add(KStudioEventStreamDataTypeIds.BodyIndex);
    
                // Create the recording object
                using (KStudioRecording recording = this.client.CreateRecording(filePath, streamCollection))
                {
                    recording.StartTimed(this.duration);
                    while (recording.State == KStudioRecordingState.Recording)
                    {
                        Thread.Sleep(500);
                    }
                }
    
                // Update UI after the background recording task has completed
                this.isRecording = false;
                this.Dispatcher.BeginInvoke(new NoArgDelegate(UpdateButtonState));
            }
    
            /// <summary>
            /// Plays back a .xef file to the Kinect sensor
            /// </summary>
            private void PlaybackClip(string filePath)
            {
                // Create the playback object
                using (KStudioPlayback playback = client.CreatePlayback(filePath))
                {
                    playback.LoopCount = this.loopCount;
                    playback.Start();
    
                    while (playback.State == KStudioPlaybackState.Playing)
                    {
                        Thread.Sleep(500);
                    }
                }
    
                // Update the UI after the background playback task has completed
                this.isPlaying = false;
                this.Dispatcher.BeginInvoke(new NoArgDelegate(UpdateButtonState));
            }  

    And what the content of the function UpdateButtonState()?

    Tuesday, March 31, 2015 11:32 AM

All replies

  • Angela, is most likely the best person to answer this, however from looking at the code it appears all it would do is change the state of the button to "enabled" or "disabled" while the recording is happening, or maybe show some message showing that the recording is occurring. I don't think this has anything other than updating the User Interface of the button on the main thread.

    As far as the ArgumentException, it's most likely the options you're selecting for the

    KStudioEventStreamSelectorCollection

    variable. There are certain options you must select, and others you can't select. For an example look at Kinect Studio and try to select some of the streams, you'll notice that when you select BodyIndex you can't have RawIR selected and etc. Another example is Depth requires IR, etc. You'll have to play around with the options to make sure they are valid.


    Sr. Enterprise Architect | Trainer | Consultant | MCT | MCSD | MCPD | SharePoint TS | MS Virtual TS |Windows 8 App Store Developer | Linux Gentoo Geek | Raspberry Pi Owner | Micro .Net Developer | Kinect For Windows Device Developer |blog: http://dgoins.wordpress.com

    Tuesday, March 31, 2015 2:54 PM