Пример #1
0
        /// <summary>
        /// Performs OCR on project images.
        /// </summary>
        /// <returns></returns>
        public ActionResult PerformOcr()
        {
            Gallery.RecognizableElementOcrCompleted += Gallery_RecognizableElementOcrCompleted;
            _longOperationsDataContainer             = new LongOperationsData(0, Gallery.GetRecognizableElementsQuantity(), Properties.Resources.PerformOcr_CurrentIterationMessageTemplate, Properties.Resources.PerformOcr_Description);
            ProjectElementOcrCompleted?.Invoke(this, new LongOperationsDataEventArgs(_longOperationsDataContainer));

            try
            {
                foreach (GalleryImage image in Gallery.Images)
                {
                    image.PerformOcr(DataColumns);
                }

                return(new ActionResult());
            }
            catch (Exception e)
            {
                LogHelper.Logger.Error(e, $"Unable to perform OCR in the project '{Name}'");
                return(new ActionResult(ActionResultType.Error, e.Message));
            }
            finally
            {
                _longOperationsDataContainer             = null;
                Gallery.RecognizableElementOcrCompleted -= Gallery_RecognizableElementOcrCompleted;
            }
        }
Пример #2
0
 private void Gallery_RecognizableElementOcrCompleted(object sender, EventArgs eventArgs)
 {
     if (_longOperationsDataContainer != null)
     {
         _longOperationsDataContainer.Iterate();
         ProjectElementOcrCompleted?.Invoke(this, new LongOperationsDataEventArgs(_longOperationsDataContainer));
     }
 }