Exemplo n.º 1
0
        /// <summary>
        /// Reconfigures the exporting parameters and starts the second part
        /// of the batch export.
        /// </summary>
        private void batchExportPart1Finished(
            OpenNIRecordingController sender,
            DirectoryInfo exportDir, List <int> frames, List <int> userIDs,
            ImageDictionary exportedFiles2D,
            ImageDictionary exportedFiles3D, bool ExportRelativePathNames,
            String export_filename_suffix)
        {
            // Report success.
            lazyInvoke((MethodInvoker) delegate
            {
                exportForm.textBoxProgress.Text =
                    "Exporting standard images finished (Batch export part 1)." +
                    "Generating data index file...";
            });


            try
            {
                if (exportedFiles2D != null)
                {
                    using (FileStream write_to = File.OpenWrite(
                               Path.Combine(exportDir.FullName, "Export2D" + export_filename_suffix + ".xml")))
                    {
                        movementDataSerializer.Serialize(write_to, exportedFiles2D);
                    }
                }
                if (exportedFiles3D != null)
                {
                    using (FileStream write_to = File.OpenWrite(
                               Path.Combine(exportDir.FullName, "Export3D" + export_filename_suffix + ".xml")))
                    {
                        movementDataSerializer.Serialize(write_to, exportedFiles3D);
                    }
                }
            }
            catch (Exception e)
            {
                showException("Error creating data index file: \n" +
                              e.Message);
            }

            // Configure for the second export.
            // Check whether the user selected to do a batch export.
            OpenNIRecordingController exportVideo = sender;

            exportVideo.ExportFinished -= batchExportPart1Finished;
            exportVideo.ExportFinished += batchExportPart2Finished;

            // Reset progress bar.
            lazyInvoke((MethodInvoker) delegate
            {
                exportForm.progressBar.Value    = 0;
                exportForm.textBoxProgress.Text = "Initializing batch export part 2...";
            });

            // Begin exporting.
            exportVideo.ExportFrames(
                frames,
                userIDs,
                (exportedFiles2D != null),
                (exportedFiles3D != null),
                ExportRelativePathNames,
                true, true, true, false, false,
                exportDir);
        }
Exemplo 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);
        }