/// <summary> /// Сохранение обработанного видео в виде набора ключевых кадров /// </summary> private async void SaveVideoFileFunction() { try { progressWindow = ProgressWindow.InitializeProgressWindow(); SaveFileDialog dialog = new SaveFileDialog(); dialog.ShowDialog(); string XMLFileName = System.IO.Path.Combine(dialog.FileName, System.IO.Path.GetFileNameWithoutExtension(dialog.FileName) + ".xml"); VideoSaver videoSaver = new VideoSaver(); VideoSaver.videoFrameSavedEvent += this.VideoFrameSavedProcessing; System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Red, 2); progressWindow.pbStatus.Value = 0.0; if (this.video != null && this.video.Frames != null) progressWindow.pbStatus.SmallChange = (double)progressWindow.pbStatus.Maximum / (double)this.video.Frames.Count; progressWindow.capitalText.Text = SAVE_PROCESSED_VIDEO_FRAMES_STRING; progressWindow.textInformation.Text = ""; progressWindow.Show(); if (this.video != null && this.video.Frames != null) { await videoSaver.SaveVideoAsync(this.video, pen, dialog.FileName, "ProcessedFrames", ".jpg"); await DigitalVideoProcessingLib.IO.XMLWriter.WriteTextBlocksInformation(video, XMLFileName); } else { await videoSaver.SaveVideoAsync(this.processedVideoFramesBitmapForSave, dialog.FileName, "ProcessedFrames", ".jpg"); await DigitalVideoProcessingLib.IO.XMLWriter.WriteTextBlocksInformation(this.textRegionsDictionary, XMLFileName); } OkButtonWindow okButtonWindow = OkButtonWindow.InitializeOkButtonWindow(); okButtonWindow.capitalText.Text = SAVE_PROCESSED_VIDEO_FRAMES_STRING; okButtonWindow.textInformation.Text = SAVE_PROCESSED_VIDEO_FRAMES_SUCCESS_STRING; progressWindow.Hide(); okButtonWindow.ShowDialog(); } catch (Exception exception) { progressWindow.Hide(); ShowExceptionMessage(exception.Message); } }
/// <summary> /// Сохранение единичного кадра видео после обработки /// </summary> private async void SaveVideoFrameFunction() { try { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "JPEG Image (.jpg)|*.jpg"; dialog.ShowDialog(); string pathToSaveFile = System.IO.Path.GetDirectoryName(dialog.FileName); string XMLFileName = System.IO.Path.Combine(pathToSaveFile, System.IO.Path.GetFileNameWithoutExtension(dialog.FileName) + ".xml"); VideoSaver videoSaver = new VideoSaver(); System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Red, 2); await videoSaver.SaveVideoFrameAsync(videoFrame, pen, dialog.FileName); await DigitalVideoProcessingLib.IO.XMLWriter.WriteTextBlocksInformation(videoFrame, XMLFileName); OkButtonWindow okButtonWindow = OkButtonWindow.InitializeOkButtonWindow(); okButtonWindow.capitalText.Text = SAVE_FRAME_STRING; okButtonWindow.textInformation.Text = SAVE_FRAME_SUCCESS_STRING; okButtonWindow.ShowDialog(); } catch (Exception exception) { ShowExceptionMessage(exception.Message); } }