예제 #1
0
        /// <summary>
        /// Clean up necessary things before closing.
        /// </summary>
        private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Clean up.
            if (videoDisplay.Source != null)
            {
                OpenNIImageProvider src = videoDisplay.Source;
                videoDisplay.Source = null;
                src.Shutdown();
            }

            // Save the settings.
            try
            {
                Settings.Default.ProjectDirectory = projectDirectory;
                Settings.Default.Save();
            }
            catch
            { }
        }
예제 #2
0
        private void buttonStartCapturing_Click(object sender, EventArgs e)
        {
            if (buttonStartCapturing.Text.Equals(BUTTON_START_CAPTURING_START_TEXT))
            {
                try
                {
                    DirectoryInfo containing    = new DirectoryInfo(this.projectDirectory);
                    String        prefix        = DateTime.Now.ToString("yyyy-MM-dd-Take-");
                    DirectoryInfo captureFolder = OpenNIImageProvider.
                                                  GetNewFolderWithHigherIndex(containing, prefix, "-");

                    labelCaptureSubfolderContent.Text = captureFolder.Name;
                    kinect.StartRecording(captureFolder, true);
                }
                catch (Exception exc)
                {
                    showException(exc.Message);
                }
            }
            else
            {
                kinect.StopRecording();
            }
        }
예제 #3
0
        /// <summary>
        /// Initializes the export.
        /// </summary>
        private void buttonExport_Click(object sender, EventArgs e)
        {
            OpenNIRecordingController exportVideo = videoDisplay.Source as OpenNIRecordingController;

            if (exportVideo == null)
            {
                return;
            }

            // Stop playback before configuration.
            exportVideo.StopPlayback();

            // Select frames to export
            List <int> export_frames = new List <int>(
                Math.Abs(trackBarVideo.LastHighlightedFrame - trackBarVideo.FirstHighlightedFrame));

            for (int i = trackBarVideo.FirstHighlightedFrame; i <= trackBarVideo.LastHighlightedFrame; i++)
            {
                export_frames.Add(i);
            }

            Dictionary <int, int> statistics = exportVideo.GetUserStatistics(export_frames);

            // Show export configuration dialog.
            ExportConfiguration configuration_form = new ExportConfiguration(
                statistics, export_frames);

            configuration_form.ImageSensorData = exportVideo.ImageOrDepth;
            configuration_form.DrawBackground  = exportVideo.DrawBackground;
            configuration_form.DrawHighlight   = exportVideo.DrawUserHighlight;
            configuration_form.DrawLabels      = exportVideo.DrawUserInformation;
            configuration_form.DrawSkeleton    = exportVideo.DrawSkeletonMesh;

            configuration_form.ShowDialog(this);
            if (configuration_form.DialogResult == DialogResult.Cancel)
            {
                return;
            }

            // Set paralellization event handlers.
            exportVideo.ExportMadeProgress += exportMadeProgress;
            exportVideo.ExportFailed       += exportFailed;

            // Check whether the user selected to do a batch export.
            if (configuration_form.DoBatchExport)
            {
                exportVideo.ExportFinished += batchExportPart1Finished;
                // Configure for the first batch export part and ignore
                // the corresponding user preferences.
                configuration_form.ImageSensorData = true;
                configuration_form.DrawBackground  = true;
                configuration_form.DrawSkeleton    = false;
                configuration_form.DrawHighlight   = false;
                configuration_form.DrawLabels      = false;
            }
            else
            {
                exportVideo.ExportFinished += exportFinished;
            }

            // Display progress bar.
            exportForm.progressBar.Value    = 0;
            exportForm.textBoxProgress.Text = "Initializing export...";
            exportForm.Show(this);

            // Prepare export directory.
            FileInfo      recording = new FileInfo(exportVideo.RecordingFilename);
            DirectoryInfo recordDir = recording.Directory;
            DirectoryInfo exportDir = OpenNIImageProvider.
                                      GetNewFolderWithHigherIndex(recordDir, EXPORT_DIR_PREFIX, "-");

            // Begin exporting.
            exportVideo.ExportFrames(
                export_frames,
                configuration_form.SelectedUsers,
                configuration_form.AnnotationIn2D,
                configuration_form.AnnotationIn3D,
                configuration_form.ExportRelativePathNames,
                configuration_form.ImageSensorData,
                configuration_form.DrawBackground,
                configuration_form.DrawSkeleton,
                configuration_form.DrawHighlight,
                configuration_form.DrawLabels,
                exportDir);
        }