/// <summary>
        /// Сохранение одного кадра видео
        /// </summary>
        /// <param name="videoFrame"></param>
        /// <param name="pen"></param>
        /// <param name="saveFileName"></param>
        public Task<bool> SaveVideoFrameAsync(GreyVideoFrame videoFrame, System.Drawing.Pen pen, string saveFileName)
        {
            try
            {
                if (videoFrame == null || videoFrame.Frame == null)
                    throw new ArgumentNullException("Null videoFrame");
                if (saveFileName == null || saveFileName.Length == 0)
                    throw new ArgumentNullException("Null saveFileName");
                if (pen == null)
                    throw new ArgumentNullException("Null pen");

                return Task.Run(() =>
                {
                    BitmapConvertor bitmapConvertor = new BitmapConvertor();
                    Bitmap bitmapFrame = bitmapConvertor.ToBitmap(videoFrame.Frame);

                    Draw.DrawTextBoundingBoxes(bitmapFrame, videoFrame.Frame.TextRegions, pen);
                    bitmapFrame.Save(saveFileName);

                    return true;
                });
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
        /// <summary>
        /// Выделение текста на на единичном кадре видео
        /// </summary>
        private async void DetectVideoFrameTextFunction()
        {
            try
            {
                EvristicsWindow evristicsWindow = EvristicsWindow.InitializeEvristicsWindow();
                evristicsWindow.capitalText.Text = PARAMETERS_SETTING_STRING;
                evristicsWindow.ShowDialog();

                AlgorithmParametersWindow algorithmParametersWindow = AlgorithmParametersWindow.InitializeAlgorithmParametersWindow();
                algorithmParametersWindow.capitalText.Text = PARAMETERS_SETTING_STRING;
                algorithmParametersWindow.ShowDialog();

                EvristicsWindowViewModel evristicsWindowDataContext = (EvristicsWindowViewModel)evristicsWindow.DataContext;
                AlgorithmParametersViewModel algorithmParametersWindowDataContext = (AlgorithmParametersViewModel)algorithmParametersWindow.DataContext;

                SWTVideoTextDetection SWTVideoTextDetection = new SWTVideoTextDetection(evristicsWindowDataContext.VarienceAverageSWRation,
                    algorithmParametersWindowDataContext.GaussFilterSize, algorithmParametersWindowDataContext.GaussSigma, algorithmParametersWindowDataContext.CannyLowTreshold,
                    algorithmParametersWindowDataContext.CannyHighTreshold, evristicsWindowDataContext.AspectRatio, evristicsWindowDataContext.DiamiterSWRatio,
                    evristicsWindowDataContext.BbPixelsNumberMinRatio, evristicsWindowDataContext.BbPixelsNumberMaxRatio,
                    evristicsWindowDataContext.ImageRegionHeightRationMin, evristicsWindowDataContext.ImageRegionWidthRatioMin, evristicsWindowDataContext.PairsHeightRatio,
                    evristicsWindowDataContext.PairsIntensityRatio, evristicsWindowDataContext.PairsSWRatio, evristicsWindowDataContext.PairsWidthDistanceSqrRatio,
                    evristicsWindowDataContext.PairsOccupationRatio, evristicsWindowDataContext.MinLettersNumberInTextRegion,
                    evristicsWindowDataContext.MergeByDirectionAndChainEnds, evristicsWindowDataContext.UseAdaptiveSmoothing);

                this.StartLoader(DETECT_TEXT_VIDEO_FRAME_STRING);
                await SWTVideoTextDetection.DetectText(this.videoFrame, 4);
                this.StopLoader();

                OkButtonWindow okButtonWindow = OkButtonWindow.InitializeOkButtonWindow();
                okButtonWindow.capitalText.Text = FRAME_PROCESS_STRING;
                okButtonWindow.textInformation.Text = FRAME_PROCESS_SUCCESS_STRING;
                okButtonWindow.ShowDialog();

                BitmapConvertor bitmapConvertor = new BitmapConvertor();
                Bitmap bitmapFrame = bitmapConvertor.ToBitmap(this.videoFrame.Frame);
                Draw.DrawTextBoundingBoxes(bitmapFrame, this.videoFrame.Frame.TextRegions, new System.Drawing.Pen(System.Drawing.Color.Red, 2));

                BitmapImageConvertor bitmapImageConvertor = new Convertors.BitmapImageConvertor();
                this.ProcessedFrameSource = bitmapImageConvertor.BitmapToBitmapImage(bitmapFrame);

                this.IsVideoFrameTabSelected = false;
                this.IsProcessedVideoFramesTabSelected = false;
                this.IsProcessedVideoFrameTabSelected = true;
                this.IsVideoTabSelected = false;
            }
            catch (Exception exception)
            {
                this.StopLoader();
                ShowExceptionMessage(exception.Message);
            }
        }      
        private void AddProcessedFrameToBitmapArray(GreyVideoFrame videoFrame)
        {
            try
            {
                if (this.processedVideoFramesBitmap == null)
                    this.processedVideoFramesBitmap = new List<BitmapImage>();
                if (this.processedVideoFramesBitmapForSave == null)
                    this.processedVideoFramesBitmapForSave = new List<Bitmap>();
                if (this.textRegionsDictionary == null)
                    this.textRegionsDictionary = new Dictionary<int, List<TextRegion>>();

                this.textRegionsDictionary.Add(videoFrame.FrameNumber, videoFrame.Frame.TextRegions);

                BitmapConvertor bitmapConvertor = new BitmapConvertor();
                BitmapImageConvertor bitmapImageConvertor = new Convertors.BitmapImageConvertor();

                Bitmap bitmapFrame = bitmapConvertor.ToBitmap(videoFrame.Frame);
                Draw.DrawTextBoundingBoxes(bitmapFrame, videoFrame.Frame.TextRegions, new System.Drawing.Pen(System.Drawing.Color.Red, 2));
                this.processedVideoFramesBitmapForSave.Add(bitmapFrame);
                this.processedVideoFramesBitmap.Add(bitmapImageConvertor.BitmapToBitmapImage(bitmapFrame));      
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
        /// <summary>
        /// Запись обработанных ключевых кадров видео в виде BitmapImage, отрисовка прямоугольников текстовых областей
        /// </summary>
        private void CreateBitmapsFromProcessedVideoFrames()
        {
            try
            {
                this.processedVideoFramesBitmap = new List<BitmapImage>();
                BitmapConvertor bitmapConvertor = new BitmapConvertor();
                BitmapImageConvertor bitmapImageConvertor = new Convertors.BitmapImageConvertor();

                for (int i = 0; i < this.video.Frames.Count; i++)
                {
                    Bitmap bitmapFrame = bitmapConvertor.ToBitmap(this.video.Frames[i].Frame);
                    Draw.DrawTextBoundingBoxes(bitmapFrame, this.video.Frames[i].Frame.TextRegions, new System.Drawing.Pen(System.Drawing.Color.Red, 2));
                    this.processedVideoFramesBitmap.Add(bitmapImageConvertor.BitmapToBitmapImage(bitmapFrame));
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }