/// <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);
        }
Ejemplo n.º 2
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);
        }