Ejemplo n.º 1
0
        private void StartOCR(Stream stream, string filename)
        {
            if (stream != null && stream.Length > 0 && !string.IsNullOrEmpty(filename))
            {
                cbLanguages.Enabled = btnStartOCR.Enabled = txtResult.Enabled = false;
                pbProgress.Visible  = true;

                TaskEx.Run(() =>
                {
                    try
                    {
                        OCRSpace ocr = new OCRSpace(Language, false);
                        OCRSpaceResponse response = ocr.DoOCR(stream, filename);

                        if (response != null && !response.IsErroredOnProcessing && response.ParsedResults.Count > 0)
                        {
                            Result = response.ParsedResults[0].ParsedText;
                        }
                    }
                    catch (Exception e)
                    {
                        DebugHelper.WriteException(e);
                    }
                },
                           () =>
                {
                    if (!IsDisposed)
                    {
                        UpdateControls();
                        cbLanguages.Enabled = btnStartOCR.Enabled = txtResult.Enabled = true;
                        pbProgress.Visible  = false;
                    }
                });
            }
        }
Ejemplo n.º 2
0
        public async Task PlanetaryProduction([Remainder] string argsString = null)
        {
            if (argsString == null)
            {
                await ReplyAsync($"No commands passed. For help type !pi help");
            }
            else
            {
                var imageUrl = new Uri(argsString);

                var ocr = await _ocr.DoOCR(imageUrl);
            }
        }