コード例 #1
0
        /// <summary>
        /// Одновременное считывание и обработка кадра видеопотока
        /// </summary>
        /// <param name="sWTVideoTextDetection">Детектор текста</param>
        /// <param name="frameLoader">Загрузчик кадра</param>
        /// <param name="keyFrameIOInformation">Информация об извлекаемом кадре</param>
        /// <param name="videoFileName">Имя видеофайла</param>
        /// <param name="threadsNumber">Число потоков для выделения текста</param>
        /// <returns></returns>
        public async static Task LoadDetectTextVideo(SWTVideoTextDetection sWTVideoTextDetection, FrameLoader frameLoader,
            List<KeyFrameIOInformation> keyFrameIOInformation, string videoFileName, int threadsNumber)
        {
            try
            {
                if (sWTVideoTextDetection == null)
                    throw new ArgumentNullException("Null sWTVideoTextDetection in LoadDetectTextVideo");
                if (frameLoader == null)
                    throw new ArgumentNullException("Null frameLoader in LoadDetectTextVideo");
                if (keyFrameIOInformation == null)
                    throw new ArgumentNullException("Null keyFrameIOInformation in LoadDetectTextVideo");
                if (videoFileName == null)
                    throw new ArgumentNullException("Null videoFileName in LoadDetectTextVideo");              

                for (int i = 0; i < keyFrameIOInformation.Count; i++)
                {
                    GreyVideoFrame frame = await frameLoader.LoadFrameAsync(videoFileName, keyFrameIOInformation[i]);
                    await sWTVideoTextDetection.DetectText(frame, threadsNumber);
                    FrameWasProcessedEvent(frame);
                }               
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
コード例 #2
0
        /// <summary>
        /// Загрузка единичного кадра видео 
        /// </summary>
        private async void LoadVideoFrameFunction()
        {
            try
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "JPEG Image (.jpg)|*.jpg";
                dialog.ShowDialog();

                FrameSizeWindow frameSizeWindow = FrameSizeWindow.InitializeFrameSizeWindow();
                frameSizeWindow.capitalText.Text = PARAMETERS_SETTING_STRING;
                frameSizeWindow.ShowDialog();

                FrameSizeViewModel frameSizeViewModel = (FrameSizeViewModel)frameSizeWindow.DataContext;

                IOData ioData = new IOData() { FileName = dialog.FileName, FrameHeight = frameSizeViewModel.FrameHeight, FrameWidth = frameSizeViewModel.FrameWidth };
                VideoLoader.frameLoadedEvent += this.LoadingFramesProcessing;
                VideoLoader videoLoader = new VideoLoader();

                FrameLoader frameLoader = new FrameLoader();
                videoFrame = await frameLoader.LoadFrameAsync(ioData);

                OkButtonWindow okButtonWindow = OkButtonWindow.InitializeOkButtonWindow();
                okButtonWindow.textInformation.Text = LOAD_FRAME_SUCCESS_STRING;
                okButtonWindow.capitalText.Text = LOAD_FRAME_STRING;
                okButtonWindow.ShowDialog();

                Bitmap bitmapFrame = new Bitmap(dialog.FileName);
                BitmapImageConvertor bitmapImageConvertor = new Convertors.BitmapImageConvertor();
                this.FrameSource = bitmapImageConvertor.BitmapToBitmapImage(bitmapFrame);
                this.ProcessedFrameSource = null;

                this.IsVideoFrameTabSelected = true;
                this.IsProcessedVideoFramesTabSelected = false;
                this.IsProcessedVideoFrameTabSelected = false;
                this.IsVideoTabSelected = false;
            }
            catch (Exception exception)
            {
                ShowExceptionMessage(exception.Message);
            }
        }