Пример #1
0
        async void RecordButton_Click(object sender, RoutedEventArgs e)
        {
            if (_recorder == null)
            {
                var picker = new FileSavePicker();
                picker.FileTypeChoices.Add("KinectEx.DVR Files", new List<string>() {".kdvr"});
                picker.DefaultFileExtension = ".kdvr";
                picker.SuggestedFileName = DateTime.Now.ToString("MM-dd-yyyy-hh-mm-ss");

                var file = await picker.PickSaveFileAsync();

                if (file != null)
                {
                    // NOTE : Unlike the WPF sample which uses the "Automatic" mode, this example
                    //        shows the use of the manual recording mode and does some work to
                    //        optimize the recording process. The result is a better experience
                    //        for this application and a better recording because fewer frames
                    //        end up getting lost.
                    _recorder = new KinectRecorder(await file.OpenStreamForWriteAsync());

                    // NOTE : Default ColorRecorderCodec is Raw @ 1920 x 1080. Only need to change the
                    //        bits that differ from the default.

                    int colorCompressionType = ColorCompressionCombo.SelectedIndex / 3;
                    int colorCompressionSize = ColorCompressionCombo.SelectedIndex % 3;
                    if (colorCompressionType == 1)
                    {
                        _recorder.ColorRecorderCodec = new JpegColorCodec();
                    }
                    if (colorCompressionSize == 1) // 1280 x 720
                    {
                        _recorder.ColorRecorderCodec.OutputWidth = 1280;
                        _recorder.ColorRecorderCodec.OutputHeight = 720;
                    }
                    else if (colorCompressionSize == 2) // 640 x 360
                    {
                        _recorder.ColorRecorderCodec.OutputWidth = 640;
                        _recorder.ColorRecorderCodec.OutputHeight = 360;
                    }

                    _recorder.Start();

                    RecordButton.Content = "Stop Recording";
                    BodyCheckBox.IsEnabled = false;
                    ColorCheckBox.IsEnabled = false;
                    DepthCheckBox.IsEnabled = false;
                    InfraredCheckBox.IsEnabled = false;
                    ColorCompressionCombo.IsEnabled = false;
                }
            }
            else
            {
                RecordButton.IsEnabled = false;

                await _recorder.StopAsync();
                _recorder = null;

                RecordButton.Content = "Record";
                RecordButton.IsEnabled = true;
                BodyCheckBox.IsEnabled = true;
                ColorCheckBox.IsEnabled = true;
                DepthCheckBox.IsEnabled = true;
                InfraredCheckBox.IsEnabled = true;
                ColorCompressionCombo.IsEnabled = true;
            }
        }
Пример #2
0
        async void RecordButton_Click(object sender, RoutedEventArgs e)
        {
            if (_recorder == null)
            {
                var dlg = new SaveFileDialog()
                {
                    FileName = DateTime.Now.ToString("MM-dd-yyyy-hh-mm-ss"),
                    DefaultExt = ".kdvr",
                    Filter = "KinectEx.DVR Files (*.kdvr)|*.kdvr"
                };

                if (dlg.ShowDialog().GetValueOrDefault())
                {
                    _recorder = new KinectRecorder(File.Open(dlg.FileName, FileMode.Create), _sensor);
                    _recorder.EnableBodyRecorder = BodyCheckBox.IsChecked.GetValueOrDefault();
                    _recorder.EnableColorRecorder = ColorCheckBox.IsChecked.GetValueOrDefault();
                    _recorder.EnableDepthRecorder = DepthCheckBox.IsChecked.GetValueOrDefault();
                    _recorder.EnableInfraredRecorder = InfraredCheckBox.IsChecked.GetValueOrDefault();

                    // NOTE : Default ColorRecorderCodec is Raw @ 1920 x 1080. Only need to change the
                    //        bits that differ from the default.

                    int colorCompressionType = ColorCompressionCombo.SelectedIndex / 3;
                    int colorCompressionSize = ColorCompressionCombo.SelectedIndex % 3;
                    if (colorCompressionType == 1)
                    {
                        _recorder.ColorRecorderCodec = new JpegColorCodec();
                    }
                    if (colorCompressionSize == 1) // 1280 x 720
                    {
                        _recorder.ColorRecorderCodec.OutputWidth = 1280;
                        _recorder.ColorRecorderCodec.OutputHeight = 720;
                    }
                    else if (colorCompressionSize == 2) // 640 x 360
                    {
                        _recorder.ColorRecorderCodec.OutputWidth = 640;
                        _recorder.ColorRecorderCodec.OutputHeight = 360;
                    }

                    _recorder.Start();

                    RecordButton.Content = "Stop Recording";
                    BodyCheckBox.IsEnabled = false;
                    ColorCheckBox.IsEnabled = false;
                    DepthCheckBox.IsEnabled = false;
                    ColorCompressionCombo.IsEnabled = false;
                }
            }
            else
            {
                RecordButton.IsEnabled = false;

                await _recorder.StopAsync();
                _recorder = null;

                RecordButton.Content = "Record";
                RecordButton.IsEnabled = true;
                BodyCheckBox.IsEnabled = true;
                ColorCheckBox.IsEnabled = true;
                DepthCheckBox.IsEnabled = true;
                ColorCompressionCombo.IsEnabled = true;
            }
        }